Is this an echojson string? {Code...} is this the echo json string?
Function my () {... echo {"code": "NO_ERROR", "msg": "system parameter retrieved "}}
Reply content:
Is that the echo json string?
Function my () {... echo {"code": "NO_ERROR", "msg": "system parameter retrieved "}}
$. Ajax ({type: "GET", url: "http://www.example.com/json.php", data: {name: "ele", pass: "123"}, // here data is a parameter, success: function (data) {console. log (data );}});
'No _ error', 'MSG '=> 'system parameter Retrieved successfully',); header ('content-Type: application/json; charset = utf-8 '); echo json_encode ($ arr );
Although you are not clear about the specific problem scenarios, I have answered with my development experience that I have encountered java to retrieve the json returned by php. However, when json_encode is an empty array, java cannot be identified. in this case, you must add another judgment to determine whether the input object is null:json_encode(array('data' => (empty($data) ? new stdclass() : $data)))
Writing strings by yourself is prone to errors, such as special strings. we recommend using json_encode ($ obj) a powerful php method.
In fact, this is not necessary. it is a lot of trouble to write this code. it is generally written as an array. Then json_encode is enough.
$this->ajaxReturn(json_encode($data), "JSON");