Not being able to use Json data from php page in jquery -
i'm trying parse json data sent php page using jquery in result : {
i don't know how fix it, i'm creating json data in php below code :
$load_op_cm = $dbm -> runquery("select * at_ops_cmnts op_id='$op_id'",true,false); $row = mysqli_fetch_assoc($load_op_cm); $j_result = json_encode($row); echo $j_result;
and i'm trying parse data using jquery i'm using jquery post
method send data , response , , i'm trying part of data useful me : cm_1_1 : 1
not 1 of cm_
variables values.
when show response in html format it's :
this jquery code :
$(function(){ var vop_id = localstorage.getitem('op_id'); $.post("requests/ops.php", //required url of page on server { // data sending request server load_op_cm : true, op_id : vop_id }, function(response){ // required callback function var result = response; $.each(result, function (i,elem) { $("#response").text(elem); }); });
any suggestion how data ?
firstly need parse json string var result = json.parse(response);
. when iterate through need filter results include keys contain 'cm_'
var filter = "cm_"; $.each(result, function (i,elem) { if(i.indexof(filter) !== -1) { console.log(i, elem); // or whatever need do… } });
Comments
Post a Comment