I create application to write tag. It uses jQuery deferred and document.write. But when I use this, it always have page reload and the page referrer is disappear.
I have no idea of this. So if you have any idea to solve this problem, please tell me any small things.
Thank you for your help in advance.
The code is below.
$(function() {
var funcA = function(){
var d = $.Deferred();
var func1 = function(d) {
$.ajax({
type: 'GET',
url: 'http://api.openweathermap.org/data/2.5/find?q=London&mode=json&callback=?',
dataType: 'json',
success: d.resolve,
error: d.reject
});
return d.promise();
};
return func1(d).then(function(data) {
}, function() {
});
return funcA;
};
var funcB = function(d){
var d = $.Deferred();
d.then(function(){
});
d.resolve();
return d.promise();
};
var funcC = function(d){
var d = $.Deferred();
d.then(function(){
document.write('<a href="http://aaa" src="http://test">')
});
d.resolve();
return d.promise();
};
def = $.Deferred();
def.then(function(){
return funcA().then(function(){
return funcB().then(function(){
return funcC().then(function(){
});
});
});
});
def.resolve();
});
*This json url is sample. It happens any API.