ajax request in 'script' datetype
hi guys
i write some program using jquery $.ajax , i want to ask a javascript file from another web-site,the url is 'http://hq.sinajs.cn/list=sz002004' just to get the stock information and show it in my program,but when i wrote this
$.ajax({
type:"GET",
url:"http://hq.sinajs.cn/list=sz002004",
dataType:"script",
success:function(data){
alert('hq_str_sz002004');
}
});
and i find that the request url in the firebug is'http://hq.sinajs.cn/list=sz002004?_=1290440220889'
so the url is incorrect and return nothing,i dont know why
using some others url is the same result ,all has been add '?_' plus a timestamp
after several days trail ,some guy suggest me to add'cache:true' the the ajax option, like this
$.ajax({
type:"GET",
url:"http://hq.sinajs.cn/list=sz002004",
dataType:"script",
cache:'true',
success:function(data){
alert('hq_str_sz002004');
}
finally it return the right data and the url is correct
i find in the jquery source
/****************
if ( s.dataType === "script" && s.cache === null ) {
s.cache = false;
}
if ( s.cache === false && type === "GET" ) {
var ts = now();
// try replacing _= if it is there
var ret = s.url.replace(rts, "$1_=" + ts + "$2");
// if nothing was replaced, add timestamp to the end
s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
}
});
****************/
i dont know why write this ,why not add this in 'json' type or 'xml' html etc..
this is my question...it seems a bit long..