We are trying to build an embedded widget witch will be called from another domains.
My widget works fine in my local as a webpage. The problem comes when i try to call it from another page. Let's call that another site as A.
When A add my script tag, i want to make a call to my widget and embed it into A.
This is how to make call to my widget:
var widget = {
initialize : function(containerId)
{
(function($) {
var url = 'http://localhost:8002/widget.html';
$.ajax({
type: 'GET',
url: url,
async: false,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function(html) {
console.log(html);
$("#" + containerId).html(html);
},
error: function(e) {
console.log(e.message);
}
});
})(jQuery);
}
}
The problem is, after reading dozens of tutorials i still could not understand how callback functions should work. I don't know if i can achieve this with a little touch or i am on the wrong way.
is it possible to return whole html page with call? I will be grateful to all advices.