I am generating a URL using Timestamp like this :
var writeDate = function(){
var x = new Date();
year = x.getFullYear();
month = (x.getMonth()+1) < 10 ? '0'+(x.getMonth()+1) : (x.getMonth()+1);
date = x.getDate() < 10 ? '0'+x.getDate() : x.getDate();
time = x.getHours() < 10 ? '0'+x.getHours() : x.getHours();
minute = x.getMinutes() < 10 ? '0'+x.getMinutes() : x.getMinutes();
var timeStamp = String(year+'-'+month+'-'+date+' '+time+':'+minute+':00.000');
return String("http://107.20.173.235/BlufinAPI/Service/WhackAScrip.svc/GetWASOneMinuteSensexDatawithPosition?TimeStamp="+timeStamp);
}
// calling using a function
$.ajax({
cache: false,
type: "GET",
async: false,
url: writeDate(),//getting URL but not retrieving the live data
dataType: "jsonp",
success: function (msg) {
$(msg).each(function(i,value){
seArray[i]=value.CurrentPrice;
})
showResult();
},
error: function (xhr) {
console.log('update:'+msg);
}
then, i am calling my json function using returned url, but it’s retrieving the live data is it wrong anything?
Try doing encodeURI in your writeDate function for timestamp, like:
Then use in ajax url.
Hope it helps