How to post data and return multiple value as JSON data type in php
1) pro_process.php
<?php
$colName=$_POST['colName'];
$productData="p1";
$anchors="a1";
$arr=array(productData=>"$productData", anchor=>"$anchors");
$.post('pro_process.php',
{'colName':colName},
function(result) {
var obj=(jQuery.parseJSON(result)) ;
alert(obj.productData);
alert(obj.anchor);
}
);
1) pro_process.php
<?php
$colName=$_POST['colName'];
$productData="p1";
$anchors="a1";
$arr=array(productData=>"$productData", anchor=>"$anchors");
$json=json_encode($array);
echo $json;
echo $json;
?>
2) pro_process.html
$.post('pro_process.php',
function(result) {
var obj=(jQuery.parseJSON(result))
alert(obj.productData);
alert(obj.anchor);
}
);
No comments:
Post a Comment