I have a data fetching method that uses jQuery.ajax()
to fetch xml files.
/* */data: function() {
/* debug */try {
var url = arguments[0] ;
var type = arguments[1] ;
var scope = arguments[2] ;
var callback = arguments[3] ;
var self = this ;
if(this.cache[url]) {
callback(this.cache[url]) ;
} else if(!this.cache[url]) {
$.ajax({
type: "GET" ,
url: url ,
dataType: type ,
cache: false ,
success: function(data) {
if(type == "text/xml") {
var myJson = AUX.json ;
var jsonString = myJson.build(data,scope,null) ;
var jsonObject = $.parseJSON(jsonString) ;
self.cache[url] = jsonObject ;
callback(url) ;
} else if(type == "json") {
self.cache[url] = data ;
callback(url) ;
}
} ,
error: function() {
throw "Ajax call failed." ;
}
}) ;
}
/* debug */} catch(e) {
/* debug */ alert("- caller: signTutor.data\n- " + e) ;
/* debug */}
} ,
My problem is: jQuery somehow adds a parameter (?_=1272708280072
) to the url if there are escaped (hexadecimal notation) or unescaped utf-8 characters outside of the ASCII range -- i believe -- in the file name. It all works well if the file name does not contain characters in that range.
Type is set to xml
so there should not be a confusion of types. Headers of the xml files are also set adequately.
I can see from the console that jQuery throws an error, but I'm not sure as to where the problem really is.
Probably a problem with file name formatting, but I did not find any resources on the web as to AJAX file name specifications. Any ideas?
Thanks for you help!
The url parameter is a string containing the URL you want to reach with the Ajax call, while settings is an object literal containing the configuration for the Ajax request. In its first form, this function performs an Ajax request using the url parameter and the options specified in settings .
You need to specify the url because whenever you make a server request (whether it be using AJAX, or synchronous-old fashion way) you need to tell the browser who to send the request to. Almost all the examples I saw in the jQuery documentation page have a specified URL or some sort (url: "test.
AJAX allows web pages to be updated asynchronously by exchanging data with a web server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
That is a 'cache-buster' and is ignored.
The added parameter changes the url just enough to bypass most all caches that are between you and the source.
If the Url was not modified, it is likely that data would be served from any one of the caches between you and the resource, including your browser, any proxies, and perhaps the server itself.
You can find a lot of explanations on the net. Here is one.
it should be ignored.
Just to make a test, if you are using rails, don't use the javascript_include_tag
but pass the JavaScript as
<script src="/path/for/the/script/script.js" type="text/javascript"></script>
It won't enable the cache-buster and with that you can see if your problem is where you think that it is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With