php - Pass Json data using Jquery Ajax then display response -


why not working? jquery take value on change , send using ajax in json format php file. same jquery take response , append it. $(#ordersummary) never display success me verify response.

         $(document).ready(function(){     $("#prodcat").change(function(){     var prodid = $(this).val();          $("#ordersummary").append(prodid);      $.ajax({      type: 'post',      url: 'getproduct.php',      data: {'prodcat':prodid},      datatype: 'json',      success:function(response){          $("#ordersummary").append(success);        var len = response.length;        $("#product").empty();        for( var = 0; i<len; i++){        var name = response[i]['name'];        var detail = response[i]['detail'];        var price = response[i]['price'];         $("#product").append("<option value='"+name+"'>"+name+"</option>")       }      }     });    });  }); </script> 

you appending wrong varaible

change

 $("#ordersummary").append(success); 

to

 $("#ordersummary").append(response); 

or if want append success message ordersummary append ''

$("#ordersummary").append('success'); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -