Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XMLHttpRequest with password authentication?



Did you try putting the user name/password in the url?

 i.e.

http://username:email@hidden.1.1/WL_ActiveTable.asp

Thanks,
jl

> Has anyone used XMLHttpRequest on a web page requiring password
> authentication? I can't get it to work. Would someone look over my
> code and see if I'm doing something obviously wrong?
> 
> I have a Linksys router that I'm trying to pull information from to
> display in a widget. I started with Apple's Blank Widget, adding code
> to request a web page. It works fine with a normal (no password
> required).  Running it in Dashboard does not work on the linksys
> page, even when sending the password in the XMLHttpRequest.open
> function. But when I open the .html file in Safari, it pops open a
> username/password box. I enter the password and it displays correctly.
> 
> My BlankWidget.js is:
> -----
> function setup()
> {
>      //target = "http://www.slashdot.org";;
>      target = "http://192.168.1.1/WL_ActiveTable.asp";;
>      loadXMLDoc(target);
>      return 0;
> }
> function loadXMLDoc(url) {
>      debug(url);
>      xmlRequest = new XMLHttpRequest();
>      xmlRequest.setRequestHeader("Cache-Control", "no-cache");
> 
>      xmlRequest.onreadystatechange = processReqChange;
> 
>      //xmlRequest.open("GET", url, true);
>      xmlRequest.open("GET", url, true, "", "linksys");
>      xmlRequest.send(null);
> }
> 
> function processReqChange() {
>      if (null == xmlRequest.readyState) {
>          debug('readyState is null');
>          return;
>      }
> 
>      if (4 != xmlRequest.readyState) {
>          debug('readyState is ' + xmlRequest.readyState);
>          debug(xmlRequest.status);
>          return;
>      }
> 
>      debug('readyState is ' + xmlRequest.readyState);
>      debug(xmlRequest.status);
> }
> -----
> 
> Debug output:
> --> http://www.slashdot.org            // normal, no password page -
> works correctly
> --> readyState is 1
> --> undefined
> --> readyState is 2
> --> 200
> --> readyState is 3
> --> 200
> --> readyState is 4
> --> 200
> 
> --> http://192.168.1.1/WL_ActiveTable.asp        // in Dashboard
> --> readyState is 1
> --> undefined
> 
> --> http://192.168.1.1/WL_ActiveTable.asp        // in Safari
> --> readyState is 1
> --> undefined                 // the Safari username/password popup
> happens here
> --> readyState is 2
> --> 200
> --> readyState is 3
> --> 200
> --> readyState is 4
> --> 200
> ----
> 
> So it seems that adding a username/password to XMLHttpRequest.open
> does absolutely nothing. The linksys only uses the password, and
> ignores a username. Even changing the username above from "" to
> "ignoreme" has no effect.
> 
> Suggestions?
> 
> Thanks,
> 
> Danny
> 
> 
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Dashboard-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/dashboard-dev/email@hidden
> 
> This email sent to email@hidden

--------------------------------------------------
John Louch         Internet #: email@hidden
(805) 541 2965


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden

References: 
 >XMLHttpRequest with password authentication? (From: Danny Rappleyea <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.