Echo Json_encode Returns a JSON object, but instead of a JSON object, it gets a string in the front-end
Front end use code to submit and process subsequent results
Function del (ID) {
if (Confirm (' Confirm to delete this keyword? ')){
$.post ('./keyword ', {op: ' del ', Id:id},function (Result) {
alert (result); Normal This section should show the Object:object, but now the display is a string
if (Result.code! = 0) {
Alert ("Delete failed! ");
}else{
Location.reload ();
}
});
}
}
The service side uses the following code to return
echo Json_encode (Array ("code" =>0));
Exit
Normally in front of the alert result this variable should be shown as object:object, but this JSON string is now displayed.
Share to: more
------Solution--------------------
$.post ('./keyword ', {op: ' del ', Id:id},function (Result) {...}, ' JSON ');
------Solution--------------------
Function del (ID) {
if (Confirm (' Confirm to delete this keyword? ')){
$.post ('./keyword ', {op: ' del ', Id:id},function (Result) {
alert (result); Normal This section should show the Object:object, but now the display is a string
if (Result.code! = 0) {
Alert ("Delete failed! ");
}else{
Location.reload ();
}
}, "JSON");
}
}