views:

44

answers:

1

I have a problem with sending some custom headers to with a jQuery ajax JSON (or JSONP) request.

Code looks like this:

$.ajax({
      beforeSend: function(xhr) {
        xhr.setRequestHeader("X-VER",       VER);
        xhr.setRequestHeader("X-TIMESTAMP", now);
     },
     type: 'GET',
     data: null,
     url: site_uri,
     dataType: 'jsonp',
     success: function(msg){$(selector).html(msg);}
});

Firebug shows no custom headers. In addition the url changes with jsonp (can I change this?)

Edit:

I found that it probably violates http://en.wikipedia.org/wiki/Same_origin_policy but have no idea how to get it fixed (the script can't be on the same domain).

Thanks for any help

+1  A: 

If you have server access, a solution would be HTTP access control modification. Otherwise, probably the best idea is some kind of reverse proxy solution, I have no idea how good of support access control has outside of Firefox.

Anders
Thanks, it will be a temporary solution but for the production server I must find another one.
veritas
@veritas, Temporary working solution has a tendency to become permanent :)
Anders