Here is my code:
$.ajax({
url: 'xxx',
success: function(data)
{
if (data.trim() == '0')
{
//IF CODE
}
else
{
//ELSE CODE
}
}
});
This code working fine everywhere where I want to use, but not working in case of Firefox extension.
I read the following stackoverflow articles but no avail: Call to $.ajax from firefox extension not working and Ajax In Firefox Plugin
Also try to use xmlHTTPRequest but the result is same.
You should use the request module given by the addon sdk. You can call and use this module only in the add-on script and not in content script.
If you need to do an ajax request from a content script use the communication between content script and addon-script. You can find the documentation here.
If you want, I have an example of code (I assume it can be difficult to read it) but it can be help you.