javascript - php get access to posted id in ajax request -


how access data that's been posted via ajax request in php. ajax request working return string of data can't seem access variable thats being passed json object. access json object contains 1 parameter.

jquery:

$.ajax({     type:'post',      url:"../../webservices/get_rating.php",     data:json.stringify({product_id:id}),     datatype:"html",     success: function(data) {         $('.ratings-content').append(data);     }, error:function(data, status, xhr) {         alert(data + "\r\n" + status + "\r\n" + xhr);        } }); 

and in php code product_id doesn't work

php:

$product_id = (int)$_post["product_id"]; echo $product_id; returns 0 

by default, $.ajax sends data in get, need set type parameter post. did not set url, data posted.

please check link more detail.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -