Home >Web Front-end >JS Tutorial >Guess why the function is called twice when getJSON calls the background json data_jquery
Recently, when doing front-end development, I used getJSON to call the background to retrieve json data. I found that the function in the background was called twice, and the function name was getMessages.
Multiple investigations combined with the experience of online brothers found that as long as the function name does not start with get There is no such problem.
I make a bold guess that when the json data is constructed when the request is returned, all functions starting with get are called, and then the return value is obtained and the response is constructed.
So, when the function starting with get is used as the action function, it is first called once in response to the request, and then called again to construct the response.