Ajax requests from xul not working in firefox 2 - javascript

I'm working on a firefox extension and have been developing it in Firefox 3, I went to test it on Firefox 2 and for some reason, none of my HTTP requests is firing. The format of the requests are below (using prototype):
theResponse = function(response){
//some code
}
new Ajax.Request(url,{
method:'get',
parameters : {url: currentURL},
onSuccess: theResponse,
onFailure: function(){ alert('Something went wrong...') }
});
I have been trying to find a solution but the closest thing I've found is something to do with cross-site HTTPrequests, anyone has any ideas?

Figured out the problem was to do with the way prototype performs HTTPrequests, switched to using jquery and no further problems ... well with HTTPrequests anyway.

Related

jQuery .on() or click() not working inside in-app Facebook browser

I have a scenario where I want to know if a quiz is started. I implemented this:
$('#choice_3_1_0').on('change', function () {
jQuery.ajax({
url: trackgf.ajax_url,
type: 'post',
data: {
action: 'tgf_form_started'
},
success: function (response) {
console.log(response);
}
});
});
The problem here is, It works fine in all browsers. But the facebook in-app browser doesn't recognize it at all. Is there something I'm missing? Is there some browser compatibility issue here?
I have done lots of research found no clue.
The issue was the cookies. For some reason the Facebook in app browser destroys the cookie and returns null. I am still inspecting but jQuery listeners have nothing to do with it.

Check if a proxy connects in chrome extension

I'm writing a chrome extension which connects to a proxy server via the the "fixed_servers" mode in chrome.proxy. I'd like to provide a list of servers and have try to connect to all of them and stay connected to the first one that that it can reach the internet through.
I tried:
if(!navigator.onLine()){
nextProxy();
}
but that didn't work.
Thanks in advance
I ended up using an AJAX request. If the request is successful I'm online. If it's not, I'm maybe online but I'll assume offline.
var xhr = $.ajax({
url: url,
timeout: 3000,
success : function(data){
...
},
error : function(){
...
}
});

IE8 jquery ajax head request not working?

typical IE problems everyone. this works in chrome, firefox, safari - but not in IE8. haven't tried in IE9 yet. anyone know what i'm missing? i tried it with and without the crossDomain param. thanks in advance.
$.ajax({
url:'http://www.example.com/photo.jpg',
type:'HEAD',
crossDomain:true,
error: function() {
// something bad
},
success: function() {
// something cool
}
});
From here http://api.jquery.com/jQuery.ajax/:
type
Default: 'GET'
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

Mootools Request() works only once per session IE9

Issue:
I have a Mootools Request object which sends a GET request to a PHP script. The script returns an array of IDs. In every browser except IE each time a new instantiation of the Request object is made it hits the PHP backend script - no problem. BUT with IE it only every hits the PHP script once per browser session. If I clear the cache it flows through to the backend again OK, but after a browser restart or cache refresh.
Question:
Is IE blocking my requests with caching somehow?
If so I there something I can change to prevent IE from blocking the Requests?
Note:
The issue is present on IE9 and on
IE9 in compatibility mode. I have not
tested on older IE versions.
Using
page-wide no-cache is not an option.
I used a error_log() statement in my script to check whether is was getting reached or not.
Here's my code:
requestIDs : function() {
new Request({
url : "/identity/idGenerator.php?generate_ids",
method : "get",
onSuccess : function(response) {
this.container.set('html', '');
var idList = response.split(",");
console.log(idList.join(","));
}.bind(this)
}).send();
}
});
You need to prevent IE from caching the request, here is one solution.
And the right solution which is built in mootools is initializing the Request with the config param noCache:true
var myRequest = new Request({...
...
noCache:true,
...
...);
Use method: 'post' to prevent IE from caching.

Prototype + Flickr Ajax Request doesn't work with Firefox

Hi every one I have a weird issue I been working with the Flickr API, in Flickr for make a connection with the server is through url format in my case something like this
http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=10cb3dccaa050efebdc01540c1d4d227&user_id=51390557#N07&format=json
If your run into any browser you are going to get a flickr function and is ok, but Im trying to obtain with Ajax of Prototype Im doing something like
new Ajax.Request('http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=10cb3dccaa050efebdc01540c1d4d227&user_id=51390557#N07&format=json',
{
method:'get',
onSuccess: function(transport){
debugger;
var response = transport.responseText || "no response text";
alert("Success! \n\n" + response);
},
onFailure: function(){ alert('Something went wrong...') }
});
And is working good in IE but in Firefox I dont know why Im getting in the responseText a blank string "". does any have any clue what am I doing wrong?
Thanks
I guess the answer is because firefox don't accept crossdomain callings, so for this we can use JSONP the implementation for Prototype JS can found in: dandean.com/jsonp-for-prototypejs hope some body help this question and answer self question in the future =)
best
Nahum

Categories