【发布时间】:2014-07-16 05:52:34
【问题描述】:
我有以下 AJAX:
$.ajax({
url: url,
data: {"url" : hangOutUrl, "participants" : params},
dataType: 'jsonp',
success: function(){
console.log("Connected");
},
error: function(xhr, textStatus, error) {
console.log("Impossible to connect");
console.log(xhr.statusText);
console.log(textStatus);
console.log(error);
}
});
这是我控制器上的代码
def hangout_started
#Get information from hangout using ajax and widget
url = params[:url]
participants = params[:participants].split(/-/)
#Find users
caller1 = Kid.where(username: participants[0]).first
caller2 = Kid.where(username: participants[1]).first
#Set all users to busy
caller1.set_busy_status!
#Create REDIS row with user and URL
REDIS.sadd "hangout:#{caller2.id.to_s}", url
REDIS.expire "hangout:#{caller2.id.to_s}", 60
respond_to do |format|
format.json { head :ok }
end
end
这项工作很完美,只是我的控制台日志上总是显示“无法连接”。为什么我总是进入我的错误函数?
错误函数并从浏览器控制台发布错误:
消息:“jQuery211019731531548313797_1401196032110 未被调用” 堆栈:“错误:jQuery211019731531548313797_1401196032110 在 h.jsonp.b.dataTypes 的 Function.n.extend.error (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:2:1821)↵ 没有被调用↵。(匿名函数).b.converters.script json (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:16293)↵在 vc (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:7397)↵ 在 x (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:10802)↵ 在 HTMLScriptElement.n.prop.on.c (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:15583)↵ 在 HTMLScriptElement.n.event.dispatch (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:3:6404)↵ 在 HTMLScriptElement.r .handle (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:3:3179)"
【问题讨论】:
-
很难说没有更多信息。将参数记录到
error函数。 -
没有错误,只是进入我的错误:function(){ console.log("Impossible to connect"); } 但没有错误,一切正常
-
不过,
error: function(jqXHR jqXHR, String textStatus, String errorThrown) { console.log("Impossible to connect: " + textStatus + "; " + errorThrown); }之类的内容可能会帮助您找到罪魁祸首。 -
我收到此错误:hangout-blabloo.js:37 错误消息:“未调用 jQuery21107414210103452206_1401189257306”堆栈:“错误:未调用 jQuery21107414210103452206_1401189257306
标签: jquery ruby-on-rails ajax