PHP to jQuery - catching the json -


here's want do. user submits form (a single text input) , send php. php returns this;

{"status":"true","custid":"00001","custname":"john"} 

i know in json format, don't know how catch , use value can returned values.

$(function(){ $('#icnumber-form').submit(function(){             var icno  = $('#icnumber').val();     var purl  = 'php/create_process.php'      $.ajax({         type    : 'post',         url     : purl,         cache   : false,         data    : icno,         datatype: 'json',         success : function(response){             var json = $.parsejson(response);             alert(json.message);         },                    beforesend:function(){             $('.cust-exist-view').show();             }     });     return false;  }) }); 

since set datatype json, response comes parsed object, don't try parse yourself.

    success : function(response){         alert(response.status);     },                

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -