开发者

How to authenticate my form using javascript

开发者 https://www.devze.com 2023-03-19 23:51 出处:网络
there i need to authenticate before request to the url, if i use XMLHTTPRequest, things go fine var xmlHttp = ...//some code goes here

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/'

0

精彩评论

暂无评论...
验证码 换一张
取 消