How to authenticate my form using javascript
there
i need to authenticate before request to the url, if i use XMLHTTPRequest, things go fine
var xmlHttp = ...//some code goes here
xmlHttp.Open('POST','http://www.somesite.com/',false,userID,password);
xmlHttp.Send(null);
But if i need to use a form, like below
>var objForm = eval(formString);
>objForm.target='demoFrame'; //where demoFrame is an iFrame in another page
>objForm开发者_如何转开发.action='http://www.somesite.com/';
>objForm.username.value=userID;
>objForm.password.value=password;
>objForm.method='post';
>objForm.submit();
But seems that the objForm cannot use "username" & "password" as the input for authentication, since i keep receiving "authentication failed" message from the host site
Any idea?
Thanks
I assume that the other site is using HTTP Basic authentication.
Set the action
to 'http://' + userId + ':' + password + '@www.somesite.com/'
精彩评论