The cross domain JSONP type request doesn't use the XMLHttpRequest
object/system. Indeed it couldn't because XMLHttpRequest can't be done
across domains (at least not yet, standards are being formulated).

What happens is that a script tag with the requested URL is inserted
in the document, so no headers can be set.

You'll have to use a "proxy" on a local server, ie:

    http://developer.yahoo.com/javascript/howto-proxy.html

Karl Rudd

On Mon, Jan 12, 2009 at 2:20 AM, ximiff <xim...@gmail.com> wrote:
>
> I'm trying to auto login to twitter api with adding a Authorization
> header. When i run my code below , i found that the request headers
> still not modified with firebug, and the browser pop a window to input
> username and password. How can I handle that?
>
> <code>
>
> var url = "http://twitter.com/account/verify_credentials.json?
> callback=?";
>
>        $.ajax({
>          beforeSend: function(XMLHttpRequest) {
>                XMLHttpRequest.setRequestHeader("Authorization", "Basic
> eWlzdWRvbmdAZ21haWwuY29tOmV2YTBldwEs");
>          },
>          type: "GET",
>          url: url,
>          dataType: "jsonp",
>          success: function(data){
>                alert( "Data Saved: " + data["friends_count"] );
>           }
>        });
>
>
> </code>
>

Reply via email to