I'm writing a simple AJAX call in a firefox addon using jQuery that returns a full HTML page and then I attempt to get some values I need from this response. I dont know why its not working and I've done everything I could possibly think of. It works when I have my code as part of another HTML page but not as part of a Firefox extension and thats the problem: I'm writing a Firefox extension!
In the Firefox extension I get a response and I can alert, and its there (i.e. I see the response text)! but I cant call .find, .filter or anything else really. The code breaks silently at some point in the success function and nothing happens.
var myExtension = {
init: function() {
if(gBrowser) gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad, false);
},
onPageLoad: function(aEvent) {
var doc = aEvent.originalTarget;
var win = doc.defaultView;
if(doc.location.href=="http://localhost/index2.html") {
var makeTransferURL = "empty";
var pc = "empty";
$.ajax({
type: "POST",
url: "http://localhost/transfer2.html",
data: "",
cache: false,
async: false,
dataType: "html",
context: document.body,
success: function(response){
alert(response); //this works!
alert($(response).find('title').val()); // this doesnt work! neither does anything else. Why!?
},
error: function() {
alert("Sorry, The requested property could not be found.");
}
});
}
}
}
window.addEventListener("load", function() { myExtension.init(); }, false);
As I said, the alert works but the .filter .find or anything else I try and do with the response will fail. Its as if its not an object anymore.
The code itself however works when I just try it in a normal html page instead of as a firefox addon.
asked
Jul 11 '11 at 10:29
Amir
1●1