jquery - Display result on web page -


i trying result of query in json format , display result in textfield on web page. have drop down list "requesttype", when selection made need jquery lookup value mysql table , return result. far script is:

$(document).ready(function(){    $('#requesttype').change(function()      {      var department = $(this).val();      $.ajax(      {       url:"check_department.php",       type:'post',       data:{department:$(this).val()},       success:function(response)       {         $('#department').html(response);       }      });     }); }); 

using firebug see php query script returning get

{"input#department":"housekeeping"} 

i expecting "housekeeping" can't seem result in textfield on web page. textfield is: name="department". id="department".

can see going wrong?

to .ajax call add:

datatype: 'json' 

also, should use string version of json object, need:

var str = json.stringify(response.input#department); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -