Why can't ajax receive the value returned by PHP? the request is successful, but even if the alert does not come out, the console.log will not come out.

Mar.13,2021

17 line, change return json_encode to echo json_encode


check the error report. There is something wrong with your url route. Do you want to adjust the charge_index method?


if you say you have no problem, then you can see if the return format in network is not standard json, request at all, and has not reached success. Ajax

var_dump(charge_index());
Change

to

echo charge_index();

1. Write the success callback and error callback of ajax to facilitate debugging problems, but don't save trouble
2. Change var_dump to echo
3. json_encode the second parameter is not true/false

Menu