Hi there, I have this function
$.ajax({
url:aurl,
method:'GET',
beforeSend:function(req) {req.setRequestHeader('Authorization', auth);},
cache:false,
dataType:"json",
error:function() {...},
success:function(t) {...}
});
However, the parameters:
- method
- beforeSend
- Cache
are ignored by my browsers FF3, IE8 and Chrome. So, whatever is put there does not change the request sent by the browser to the given url, eg: cannot set method to "POST", or more importantly no Authorization parameter can be placed as part of the request so that the HTTP Authorization form is processed.
The other strange behaviour is that unless dataType:"json" there will be no request or response sent orreceived as shown using LiveHTTPHeaders in FF3. eg if dataType:"xml".
URL seems to get processed correctly by the browser.
How does one make sure these extra parameters get sent, anyone with these issues?
-
Is the URL remote or local?
According to JQuery Documentation
Note: All remote (not on the same domain) requests should be specified as
GETwhen'script'or'jsonp'is thedataType(because it loads script using a DOM script tag). Ajax options that require anXMLHttpRequestobject are not available for these requests. The complete and success functions are called on completion, but do not receive anXHRobject; thebeforeSendanddataFilterfunctions are not called.and for the
cacheoption, the default value is: "false fordataType'script' and 'jsonp'"Adrian33 : thanks, the dataType needed is json. The URL is remote, so I guess the options I want to set are not available.Adrian33 : I'll look into $.get() and CURL. Here for $.get it says "returns the XMLHttpRequest" http://tr.im/imZlAziz : I think this limitation is for security reasons, haven't really used it for remote urls ..
0 comments:
Post a Comment