Wx. getLocation ({code...}). In this way, if ajax is used to transmit the value to the backend controller, var_dump ($ _ POST) is a null value. why? Wx. getLocation ({
Type: 'wgs84 ', // The gps coordinate of wgs84 by default. if you want to return the Mars coordinate directly to openLocation, you can pass 'gcj02' success: function (res) {var latitude = res. latitude; // latitude, floating point number, range: 90 ~ -90 var longpolling = res. longpolling; // longitude, floating point number, range: 180 ~ -180. Var speed = res. speed; // speed, measured in meters/per second var accuracy = res. accuracy; // location accuracy $. ajax ({url: "{: U ('Home/Share/index')}", data: {latitude: latitude, longpolling: longpolling}, type: "POST ", dataType: "json", success: function (){}})},})
In this way, if ajax is used to pass values to the backend controller, var_dump ($ _ POST) is a null value. why?
Reply content:
Wx. getLocation ({
Type: 'wgs84 ', // The gps coordinate of wgs84 by default. if you want to return the Mars coordinate directly to openLocation, you can pass 'gcj02' success: function (res) {var latitude = res. latitude; // latitude, floating point number, range: 90 ~ -90 var longpolling = res. longpolling; // longitude, floating point number, range: 180 ~ -180. Var speed = res. speed; // speed, measured in meters/per second var accuracy = res. accuracy; // location accuracy $. ajax ({url: "{: U ('Home/Share/index')}", data: {latitude: latitude, longpolling: longpolling}, type: "POST ", dataType: "json", success: function (){}})},})
In this way, if ajax is used to pass values to the backend controller, var_dump ($ _ POST) is a null value. why?
The statement is correct. you need to debug your code as to why you cannot get it.
Meat test method:
Directly output the received data, and thensuccess
.
Background output: echo json_encode ($ _ POST); exit (); foreground output: success: function (msg) {console. log (msg );}
Ajax is an asynchronous request and cannot be output directly in the controller.