php - ajax POST success result not logging -
i'm making ajax post php page. on php page echo result success call log it, doesn't work.
js:
$(function(){ $.ajax({ url : "http://xxxxxxx/bn/sample.php", type : 'post', number: "1234567", success : function (result) { console.log("success"); console.log(result); }, error : function () { alert("error"); } });
php:
<?php $data = $_post['number']; echo json_encode($data); ?>
that's because you're setting number
attribute in ajax json object. correct attribute data
:
$.ajax({ url : "http://xxxxxxx/bn/sample.php", type : 'post', data: {number: "1234567"}, success : function (result) { console.log("success"); console.log(result); }, error : function () { alert("error"); } });
Comments
Post a Comment