skillful
14.07.2013, 13:50
Здравствуйте! Недавно решил использовать COMET. Вот код
this.connection = function() {
// здесь открывается соединение с сервером
self.comet = $.ajax({
type: "GET",
url: "http://host.ru/ajaxupdateonline.php",
data: {'id':self.last},
dataType: "text",
timeout: self.timeout*1000,
success: self.parseData,
error: function(){
// something wrong. but setInterval will set up connection automatically
setTimeout(self.connection,1000);
}
});
}
Все нормально работает. Но стоит в обработчике подключить какой-нибудь файл (php или txt), так сразу выходит ошибка javascripts.
Подключать пробывал:
include("http://host.ru/file.php");
require_once 'http://host.ru/file.txt';
require 'http://host.ru/file.txt';
Пути правильные.
JavaScript - http://host.ru/
Event thread: readystatechange
Uncaught exception: SyntaxError: at line 2, column 0: expected expression, got '<'
Error thrown at line 609, column 36 in <anonymous function: parseData>(message) in http://host.ru/functions.js:
i++
called via Function.prototype.apply() from line 2, column 29466 in <anonymous function: f.Callbacks>(b, f) in http://host.ru/jquery.js:
if(c[l].apply(b,f)===!1&&a.stopOnFalse)
called from line 2, column 31004 in <anonymous function: fireWith>(b, c) in http://host.ru/jquery.js:
d&&(i?a.once||d.push([b,c]):(!a.once||!e)&&n(b,c));
called from line 4, column 22304 in w(a, c, l, m) in http://host.ru/jquery.js:
v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))
called from line 4, column 34041 in <anonymous function: d>(a, e) in http://host.ru/jquery.js:
m&&g(j,k,m,l)
Как можно победить проблему?
this.connection = function() {
// здесь открывается соединение с сервером
self.comet = $.ajax({
type: "GET",
url: "http://host.ru/ajaxupdateonline.php",
data: {'id':self.last},
dataType: "text",
timeout: self.timeout*1000,
success: self.parseData,
error: function(){
// something wrong. but setInterval will set up connection automatically
setTimeout(self.connection,1000);
}
});
}
Все нормально работает. Но стоит в обработчике подключить какой-нибудь файл (php или txt), так сразу выходит ошибка javascripts.
Подключать пробывал:
include("http://host.ru/file.php");
require_once 'http://host.ru/file.txt';
require 'http://host.ru/file.txt';
Пути правильные.
JavaScript - http://host.ru/
Event thread: readystatechange
Uncaught exception: SyntaxError: at line 2, column 0: expected expression, got '<'
Error thrown at line 609, column 36 in <anonymous function: parseData>(message) in http://host.ru/functions.js:
i++
called via Function.prototype.apply() from line 2, column 29466 in <anonymous function: f.Callbacks>(b, f) in http://host.ru/jquery.js:
if(c[l].apply(b,f)===!1&&a.stopOnFalse)
called from line 2, column 31004 in <anonymous function: fireWith>(b, c) in http://host.ru/jquery.js:
d&&(i?a.once||d.push([b,c]):(!a.once||!e)&&n(b,c));
called from line 4, column 22304 in w(a, c, l, m) in http://host.ru/jquery.js:
v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))
called from line 4, column 34041 in <anonymous function: d>(a, e) in http://host.ru/jquery.js:
m&&g(j,k,m,l)
Как можно победить проблему?