Ajax, reported undefined error in thinkphp5, as shown in the figure

as shown in the picture, the undefinde error is reported, but I don"t understand the error. Please take a look at it.
clipboard.png

clipboard.png

clipboard.png

clipboard.png

Mar.20,2021

alert(data.errmsg); //  errmsg echo echo  return 

response check the results returned by the response to see what is returned


I think it is not the error of js, but the error of the result returned by the controller. If this is TP5, it should be the result of return so that the frontend can accept that


if (data.errno) is not data ['errno']


try to return the array directly. TP5 may be configured with JSON format by default.


tp5 returns json data directly to the ajax of js (['status'= > 1 json data returns = > $data]);
and then the js side is
success:function (e) {
if (e.status = = 1) {

    alert(e.data);
}                                   

}

Menu