On the PHP page, I have a drop-down list that runs the jQuery change function and does a POST with AJAX to populate the second drop-down list on the page.
Everything should be pretty simple, however Firebug throws a syntax error for '?' which appears in my code at runtime, which is not actually in my code.
This is my javascript code:
$(document).ready(function() { $('#taglist').change(function(){ $.ajax({ type: "POST", url: "../includes/ajax.php", data: "taglist=" + $(this).find("option:selected").attr('value'), dataType: 'json', success: function(response, textStatus, jqXHR) { $("#catlist").html(response.catlist); }, error: function (xhr, textStatus, errorThrown) { $("#catlist").html(xhr.responseText); } }); }); });
The following is the PHP code that runs in ajax.php:
if(isset($_POST['taglist'])){ $catlist = '<select name="cat_id[]" size="5" multiple id="cat_id[]">'; $catlist .= fillselecteditmultiple(0, 0, $_POST['taglist']); $catlist .= '</select>'; echo json_encode(array("status"=>"success", "catlist" => $catlist)); }
fillselecteditmultiple () displays the fill selection parameters that should be preselected. It works fine as I use on other pages without problems. To make sure that no error was selected from the function itself, I even tried to change the function to output the string $ catlist = 'abc' as an answer, still the same error.
The strange part is that Firebug throws an error in the last two lines of javascript code, as you can see in the attached image:


What can cause the cause ?? appear in my code?
jquery post ajax php
bikey77
source share