Ok, ignore all of that - I managed to find the problem which waiting
for the message to be moderated.

Turns out the problem I was using:

<input type="submit" value="Login" onclick="login_staff();" />

instead of

<input type="button" value="Login" onclick="login_staff();" />

Not sure why, but IE doesn't mind using type='submit' on the button,
but Firefox & Chrome won't.

On May 7, 9:06 am, hellboy1975 <[email protected]> wrote:
> Hi Guys,
>
> I'm relatively new to AJAX and Prototype, so please be gentle with me.
>
> I've been working on getting what I expected was a simple AJAX request
> into my site, and the code I've created looks right to me, however
> only works in Internet Explorer.  Initially I thought the problem
> might be Prototype, but I quickly did the same thing in jQuery, and
> that also fails in the same way.
>
> All the code is being run on localhost, and it's basically a PHP site
> running with Smarty, communicating with a Web Service responding with
> JSON.
>
> Firstly, the HTML:
>
> <html>
> <head>
>         <title>VA PHP Test Site</title>
>
>     <script type="text/javascript" src="scripts/prototype.js"></
> script>
>     <script type="text/javascript" src="scripts/va-login.js"></
> script>
>
> </head>
> <body>
> <h1>VA PHP</h1>
>
> <p>Please Log In:</p>
> <form id="login-form">
> User:
> <input type="text" name="Person" />
> <br />
> Password:
> <input type="text" name="Password" />
> <input type="submit" value="Login" onclick="login_staff();" />
> </form>
>
> <div id="login-response"></div>
> </body>
> </html>
>
> And the Javascript:
>
> function login_response(response) {
>         var login = response.responseJSON;
>         alert("State: " + login.LoginState + "\nAccount: " + login.Account +
> "\nUser: " + login.User + "\nPassword: " + login.User);
>
> }
>
> function login_staff()
> {
>         var loginString;
>         var url='LoginWSO.wso/Login_Staff/JSON';
>
>         // this sets loginString to "Person=value1&Password=value2"
>         loginString = Form.serialize("login-form");
>
>         // creates and sends the request.
>         // pops an alert if there is an error, or fires login_response when
> complete
>         var myAjax = new Ajax.Request(
>                 url,
>         {method: 'POST', parameters: loginString,  contentType:
> 'application/json',
>                         onComplete: function(response){alert('response ' +
> response.responseJSON); },
>                         onFailure: function(){ alert('Something went 
> wrong...'); }
>                 }
>     );
>
> }
>
> Just to sum it it, while using the Chrome debugger I found the
> following:
> 1. login_staff is fired, and appears to collect the various settings
> ok
> 2. onComplete occurs and the login_response function is sent - however
> the response variable is null
> 3. As a result the alert appears, but is largely blank
>
> In Internet Explorer, the alert pops up, and contains the correct
> response.
> In Firefox the behaviour is much the same as Chrome, however if I put
> a break point on, and take my time stepping through the code, the
> correct alert does actually appear.  If it let it run normally
> however, it behaves the same as Chrome.
>
> My initial thoughts were that same origin policy, but given that it's
> all on localhost, I'm not sure why this would be the case.
>
> Any suggestions gratefully appreciated!
>
> Thanks,
> Matt
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Prototype & script.aculo.us" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to