The solution that needs alert to execute after using ajax

Because AJAX is executed asynchronously by default, that is, the next line of JS statement is executed without waiting for the request to finish, resulting in null assignment.


Add the following code:

    //******other codes

It can be solved.


Read More: