I have been trying for a while to access a restless interface within a firefox addon. After reading in a bunch of places I came accross getJASONP jquery function that gets around the cross-origin resource sharing problem but it feels like a hack. Isn’t there a more elegant way of getting get and post data with jquery through a firefox plug in. I would be really surprised if a hack was the only way.
thanks.
$(document).ready(function () {
//var url = "http://132.205.237.32:8182/services";
var url ="http://127.0.0.1/learning.php";
$.getJSON(url+'?callback=?', {type:"json"}, function (results) {
alert(results.service1);
});
});
You just access them – e.g. using
XMLHttpRequest. Firefox extensions aren’t bound by same-origin policy and are allowed to request any address from the web.A side-note: Please never use JSONP in a Firefox extension, it’s a security vulnerability. By using JSONP you are running some code from the web with the privileges of your extension.