Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

trying to use timer id for ajax in listener its not working

santoshm0123
Level 2
Level 2

IN one of my dialog listener i m using ajax call where I wanted to give some timer which is not working 

what's that I m writing wrong in here. Can anyone please help me here..

 

Here is the code in my listener

function(dialog){
var path = dialog.path;
var pagePath = path.substring(0,path.indexOf("/jcr:content") + 12);
var country= this.getField("./country").getValue();
var state= this.getField("./state").getValue();
var district= this.getField("./district").getValue();
var targetUrl= this.getField("./target").getValue();
var availability= this.getField("./availability").getValue();
var showonmarketing = this.getField("./showonmarketing").getValue();
var mobileurl = this.getField("./mobileurl").getValue();
var latitude = 0;var longitude = 0;
if (pagePath){
var jcrPath = pagePath.substring(0,pagePath.indexOf("/jcr:content") + 12) + "/location" + "/" + country + "/" + state + "/" + district;
alert("BEFORE TIMERID");
alertTimerId = setTimeout(function () {
alert("after TIMERID started ");
jQuery.ajax({
url: "http://dev.virtualearth.net/REST/v1/Locations",
dataType: "jsonp",
data: {
key: "Akg_FZYIXiJc8S0ZecryN60DVoNKcHsd8fNm89pSSshPe_R4y89aoVQB8tBK02zt",
CountryRegion: country,adminDistrict: state, locality: district, output:"json"
},
jsonp: "jsonp",success: function (data) {
alert("after ajax success ");
var result = data.resourceSets[0];
if (result) {
if (result.estimatedTotal > 0) {
var coord = result.resources[0].point.coordinates;
latitude = coord[0];
longitude = coord[1];
alert("after TIMERID started inside ajax");
setLatLong(latitude,longitude,targetUrl,mobileurl,availability,jcrPath,district,showonmarketing);
alert("after setting latlong ");
}
}
},
error : function (xhr, ajaxOptions, thrownError,) {
alert("AJAX call from bing got failed");
}
});
}, 2000);

}
}

function setLatLong(latitude,longitude,targetUrl,mobileurl,availability,jcrPath,district,showonmarketing) {
CQ.Ext.Ajax.request({
url : jcrPath,
headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
params : {
url : targetUrl,
mobileurl: mobileurl,
availability : availability,
latitude : latitude,
longitude : longitude,
showonmarketing : showonmarketing,
},
success: function(objServerResponse){
console.log(objServerResponse);
alert(objServerResponse);
alert("The city you entered is Inserted");
},
failure : function(objServerResponse){
alert("error: The city is not Inserted properly, Please reenter it again");
}
});
}

0 Replies