Example Analysis of Ajax long connection Project
This article mainly introduces the example analysis of Ajax long connection project, which is very detailed and has certain reference value. Friends who are interested must finish it!
The so-called long connection is to constantly send requests, block the requests on the server side, resend the request every time the request time is exceeded, maintain the connection, and obtain the response data of the server side at any time.
Project case:
The code is as follows:
Function connection () {
$.ajax ({
Type: "GET"
Url: "/ api2/session/event?"
Data: {
"uid": obj.uid
"sessionID": "cool"
}
Success:function (serverData) {
Connection ()
}
Error:function (XMLHttpRequest, textStatus, errorThrown) {
Connection ()
}
});
}
The above is all the contents of the article "sample Analysis of the Ajax long connection Project". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!