The AJAX request code is as follows:
PHP Processing Section:
Firefox Firebug:
Can't print out what's going on???
Reply content:
The AJAX request code is as follows:
PHP Processing Section:
Firefox Firebug:
Can't print out what's going on???
I prefer to use directly $.post(settings) (in fact, prefer $.ajax(url, settings) direct), so that the parameters are more clear. The callback $.post() is $.ajax() set through or returned by the Promise done() , so the structure is relatively clear
$.post({ url: theurl, dataType: "json", data: { tablename: _tbname }}).done(function(jo) { // jo 是 javascript object // 从后端返回的 JSON 解析而来 console.log(jo);});
In your way, you can also add a parameter "JSON" directly behind the callback to represent the data type
$.post("http://url/", { tablename: _tbname}, function(data) {}, "json");
Json_encode ($data, Json_unescaped_unicode)
Even if there is no error, you restart Firefox to see it
PS: Set the response header @header ("Content-type:application/json;charset=utf8");
You can omit var json = eval (data); This step.
Also, using eval is unsafe, it is recommended to use
var json = jQuery.parseJSON(data);
Change Chrome (I am really not accustomed to Firefox debugging, you are accustomed to that even if), interrupt point debugging, mostly do not enter the method. Long time no use of Firefox, vaguely remember the past seems to have had similar problems, this in chrome should be an error, in Firefox without error. Just break it up and try Chrome if you don't get into the way.
The default returned data is a string, not a JSON object, one solution, the request parameter specifies that the return type is json,jquery internally resolves to an object, solution two, self-speaking JSON string deserialized into an object. For example: http://blog.163.com/m13864039 ...