Extracting Ajax return data in jQuery Extracting Ajax return data in jQuery jquery jquery

Extracting Ajax return data in jQuery


You can use .filter on a jQuery object that was created from the response:

success: function(data){    //Create jQuery object from the response HTML.    var $response=$(data);    //Query the jQuery object for the values    var oneval = $response.filter('#one').text();    var subval = $response.filter('#sub').text();}


Change the .find to .filter...


I have noticed that your success function has the parameter "html", and you are trying to add "data" to your elements html()... Change it so these both match:

$.ajax({    type:"POST",    url: "ajax.php",    data:"id="+id ,    success: function(data){        $("#response").html(data);    }});