3
只是一个普遍理解的快速问题。难道,开放的网络套接字连接阻止了Ajax请求?因为在web套接字连接的初始化之前ajax请求工作得很好,并且在我建立了web套接字连接之后没有任何事情发生。是一个打开的Web套接字连接阻止Ajax请求?
$.ajax({
url: someUrl
}).done(function(data) {
// stuff done and calling initWebSocket()
}).error(function(data) {
// error stuff done
});
function initWebSocket() {
hostname = 'somehost';
ws = new WebSocket('ws://' + hostname + ':' + wsPort);
ws.onopen = function() {
console.log('Connected');
ws.send(initMessage);
}
ws.onmessage = function(msg) {
// do stuff on message received
}
ws.onclose = function() {
console.log('Disconnected');
}
}
$('#someButton').click(function(event) {
event.preventDefault();
$.ajax({
url: someUrl
}).done(function(data) {
console.log(data);
}).error(function(data) {
console.log(data);
});
});
好视提到的第一个Ajax请求的工作,第二,当我点击一个按钮没有。有没有人关于这个主题的信息,如果网络套接字真的阻止Ajax请求什么是解决方案,让它运行?谢谢。
+1在使用带有SignalR的websockets时,我在Chrome中也遇到同样的问题。如果我将SignalR更改为使用longpolling,它不会阻止其他AJAX请求。想要得到这个答案。 – Paul