I want to make a simple page display statistics. The Cainiao front-end won't. I wrote a small case and ran it on github. I would like to ask all the experts for advice. Ajax: {code...} json: {code...} php: {code...
I want to make a simple page display statistics. The Cainiao front-end won't. I wrote a small case and ran it on github. I would like to ask all the experts for advice.
Ajax:
$.ajax({ url: 'php/index.php', type: 'get', dataType: 'json', data: {},}).done(function(dat) { console.log("2"); $(".header").html(dat.vp);}) .fail(function() { console.log("error");}).always(function() { console.log("complete");});
Json:
{ "vp":"0"}
Php:
The idea is that every time a page is accessed, a request is made, and PHP reads and writes the json record count (the database does not ). However, every time an ajax request enters fail. However, the PHP request status code is 200.
How can I output the entire file?
Reply content:
I want to make a simple page display statistics. The Cainiao front-end won't. I wrote a small case and ran it on github. I would like to ask all the experts for advice.
Ajax:
$.ajax({ url: 'php/index.php', type: 'get', dataType: 'json', data: {},}).done(function(dat) { console.log("2"); $(".header").html(dat.vp);}) .fail(function() { console.log("error");}).always(function() { console.log("complete");});
Json:
{ "vp":"0"}
Php:
The idea is that every time a page is accessed, a request is made, and PHP reads and writes the json record count (the database does not ). However, every time an ajax request enters fail. However, the PHP request status code is 200.
How can I output the entire file?
Open the index. php request and check whether the response meets the requirements.
Php interpreter execution.
Install a wamp and try again.
The returned json data is obviously an object, but it must be accessed using arrays.
$ Data ['VP'] = intval ($ data ['VP']) + 1; changed to $ data-> vp = $ data-> vp + 1;
My answer is absolutely correct. do not believe it.
This should be because the web server configuration is incorrect and the PHP file is not parsed.
Github does not have any server environment