views:

179

answers:

1

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?

+1  A: 

Is the URL remote or local?

According to JQuery Documentation

Note: All remote (not on the same domain) requests should be specified as GET when 'script' or 'jsonp' is the dataType (because it loads script using a DOM script tag). Ajax options that require an XMLHttpRequest object are not available for these requests. The complete and success functions are called on completion, but do not receive an XHR object; the beforeSend and dataFilter functions are not called.

and for the cache option, the default value is: "false for dataType 'script' and 'jsonp'"

Aziz
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/imZl
Adrian33
I think this limitation is for security reasons, haven't really used it for remote urls ..
Aziz