The same ajax method requests different json data returned by php. it is strange that one can have a value without a value. The following is the processing of the returned data received by my ajax method {code...}. I am very sure that obj is actually in json format. However, alert has always been the json data returned by different php requests using the same ajax method. it is strange that one can have a value without a value. The following shows how my ajax method processes the returned data.
function getUpList(_url, _u, _p){ $.ajax({ type:"GET", data:$.param({uid:_u, page:_p}), url:_url, dataType:'json', success:function(obj){ alert(obj.status); if(obj.status == 1){ $('p[name="data-list-p"]').append(obj.html); } } });}
I am very sure that obj is actually in json format. However, alert is always undefined, which is very confusing!
Reply content:
The same ajax method requests different json data returned by php. it is strange that one can have a value without a value. The following shows how my ajax method processes the returned data.
function getUpList(_url, _u, _p){ $.ajax({ type:"GET", data:$.param({uid:_u, page:_p}), url:_url, dataType:'json', success:function(obj){ alert(obj.status); if(obj.status == 1){ $('p[name="data-list-p"]').append(obj.html); } } });}
I am very sure that obj is actually in json format. However, alert is always undefined, which is very confusing!
This is amazing. you are sure the two requests are both standard.jsonData! Standard should not appearundefined. You addevalTry it!
success:function(obj){ obj = eval("("+obj+")"); alert(obj.status); if(obj.status == 1){ $('p[name="data-list-p"]').append(obj.html); }}
Did you find the data in chrome console?
Is the format of data returned from two URLs incorrect! Check if json is not standard.
Should not returnJSONFormat,JSON string, Just click it.
Both chrome and firefox can see the returned parameters for good confirmation !~
Do not rush to output. status first, output the entire obj and then the result is better ~!
Change the json code returned by php to the same one.
Well. I'm sure you got it.jsonData, but thisobjDoes havestatusAttribute?
console.log(obj);It is convenient to use this method in the console.
var obj_json = JSON.parse(obj);
String to json