Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy are updated element values not being passed?
    primarykey
    data
    text
    <p>I currently check if an input/textarea/checkbox/select changes and if so then I want to initiate my function to search the database and update the 'results' div. Now this is what I have so far..</p> <p>It works on change no problem, the only issue is now when I change a form item, it detects it but the new values are not passed to the .php file. Suggestions?</p> <p><strong>Note</strong>: I tried to use the $(this).serialize(); but it didn't work for me. I simply want to pass ALL of the specified form variables to the PHP file.</p> <pre><code>$(document).ready(function() { $("select,:checkbox").change(function(){ inits(); }); $("input,textarea").keystop(function(){ inits(); }); a = "GET"; b = "#recipeSearch"; c = $(b).attr('action') + '?r'; f = "#searchResults"; function inits(){ var values = { 'term' : $("input#searchterm").val(), 'photos' : $(b + " #requirephotos").val(), 'prep' : $(b + " #preptime").val(), 'cook' : $(b + " #cooktime").val() } console.log('Search Init'); $.ajax({ url: c, cache: false, dataType: 'json', data: values, // $(b).serialize(); // this still didn't work success: function(response) { //decoded = JSON.stringify(response); if (response) { $(f).html(response); } //$.each(r.items, function(i,data){} //usage later on }, error: function(e, jqxhr, settings, exception) { console.log('Error: ' + e.toString() + ' - ' + jqxhr); } }); } }); </code></pre> <p>Any and all suggestions are appreciated. I don't have a jsfiddle for you since it uses another script for keystop.</p> <p><strong>Example JSON</strong></p> <pre><code>{ "items": [ "item 1", "item 2", "item 3", "item 4", "item 5" ] } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload