@
@
@Twitt2017-04-06 10:35:52
Yii
@Twitt, 2017-04-06 10:35:52

Why does AJAX slow down in a Yii2 project?

Now I'm doing a project, and when you click on some buttons, Ajax should work. Example: put a "+" rating on an article. When you click on +, the AJAX request leaves, but the fact is that in the debugger its time is 1.883 MS and it fluctuates around it every time. And it's not about what is in the action, because even if the action will only return true; without any queries to the database, then the query is executed anyway 1.443 MS, which seems to be too much. Or let's say that the modal window opens, its content also opens somewhere in a second already. What could possibly be causing this? Here is the ajax example code. There seems to be nothing superfluous, but there are no misunderstandings at all.
$.ajax({
url: '/profile/like',
data: {id: id},
type: "POST",
success:

},
error: function() {
}
});

PS I created a separate test project, the usual one, so that when the button is pressed, an Ajax request is sent, and it is sent perfectly. Everything works right away. And in a project with Yii2, it’s some kind of jamb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Bukharev, 2017-04-06
@evgenybuckharev

You did not provide enough data to at least somehow understand what is the matter of such a lengthy request.
Here it should be borne in mind that there are a lot of reasons that can affect the processing time of a request.
For example, perhaps you have event handlers for a particular action, for example, afterAction, that is, before actionExample(){ return true;} is executed, afterAction event handlers, etc. will work.
The most optimal way is to profile the code, and see which section takes how much resources and time to execute

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question