Lelynx (12) [Avatar] Offline
#1
Hi,

I just tested ok the login form that is described in paragraph Posting to the server - Using HTML form. The function validateForm() runs ok.
I modified this function to use the ContentLoader of listing 512. It calls a myFormHandlerUrl.aspx server page, that just returns an xml doc containing the username and password. A callback function, affiche(), displays the returned username and password in a <div>.
validateForm is triggered by the submit button.
Problem: ContentLoader is executed although the callback function is not. An error page is returned, with error HTTP 405 - ressource not allowed.
If validateForm is triggered through window.onload, everything works fine.
So it seems the problem comes from the submit button, and I can't use the ContentLoader in this case.
Ant idea to fix it, ot get a workaround?
TIA,
Philippe

The validateFunction:

function validateForm(){
var form=document.getElementById("myForm");
var user=form.elements[0].value;
var pwd=form.elements[1].value;

//debugger;
var url="myFormHandlerUrl.aspx";
var params="username="+user+"&password="+pwd;
var loader=new net.ContentLoader(url, affiche, null, "POST", params);
}
Pascarello (208) [Avatar] Offline
#2
Re: Chap 5 - posting to the server with XMLHttpRequest _ need help!
How are you calling the validation function with the submit button?

Eric
Lelynx (12) [Avatar] Offline
#3
Re: Chap 5 - posting to the server with XMLHttpRequest _ need help!
Yes, I am!
Pascarello (208) [Avatar] Offline
#4
Re: Chap 5 - posting to the server with XMLHttpRequest _ need help!
What I meant is what is the exact code that you are using to call this validation method?

Eric
Lelynx (12) [Avatar] Offline
#5
Re: Chap 5 - posting to the server with XMLHttpRequest _ need help!
<form id="myForm" method="post" action="" onSubmit="validateForm(); return false">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" value="login" />
</form>