I have the following 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);
}
});
And this is code on my controller
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
And this work perfect, except that I always get "Impossible to connect" on my console log. Why I always enter into my error function?
Error function and post error from browser console:
message: "jQuery211019731531548313797_1401196032110 was not called" stack: "Error: jQuery211019731531548313797_1401196032110 was not called↵ at Function.n.extend.error (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:2:1821)↵ at h.jsonp.b.dataTypes.(anonymous function).b.converters.script json (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:16293)↵ at vc (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:7397)↵ at x (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:10802)↵ at HTMLScriptElement.n.prop.on.c (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:4:15583)↵ at HTMLScriptElement.n.event.dispatch (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:3:6404)↵ at HTMLScriptElement.r.handle (https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js:3:3179)"