views:

258

answers:

2

When my member registration form correctly filled in and submitted, server responds with redirect link. But my ajax does not redirect the website. I do not receive any errors, where is my mistake?

<script type="text/javascript">
 $(document).ready(function() { 
  $("[name='submit']").click(function() { 
   $.ajax({
    type: "POST",
    data: $(".form-signup").serialize(),
    url: "http://www.refinethetaste.com/FLPM/content/myaccount/signup.cs.asp?Process=Add2Member", 
    success: function(output) { 
    if (output.Redirect) {
      window.location.href = output.Redirect;
    }
    else {
     $('.sysMsg').html(output);
     }
    },
    error: function(output) {
    $('.sysMsg').html(output);
    }
   }); 
    }); 
 }); 
 </script> 

asp codes:

If Session("LastVisitedURL") <> "" Then
Response.Redirect Session("LastVisitedURL")
Else
Response.Redirect "?Section=myaccount&SubSection=myaccount"
End If
A: 

Just try this:

if (output.Redirect) {
      alert(output.Redirect);
      window.location.href = output.Redirect; 
    } 

to check what comes back from the server.

Michael Ulmann
A: 

You need to use some sort of debugger (firebug in firefox or web inspector in webkit) and stop the program at:

if (output.Redirect) {

in the success callback and at

$('.sysMsg').html(output);

in the error callback.

Then you can examine the contents and see what is in them. Without knowing what is in the object being returned (if there even is one) then no one can debug it.

Everyone needs to stop using alert and writing to a part of the page as error debugging and work straight in a debugger. Otherwise, your output also gets parsed by what is parsing it. You never know if the error is in the output or in the thing that tried to print it to the string.

I advise using both debuggers as both work differently and have their own strengths and weaknesses.

davehamptonusa