noobieChick
noobieChick

Reputation: 21

How to redirect after a successful ajax post

I have searched everywhere and I really need some help. Bout to pull all my hair out lol.

I am using ajax functions to get and post various forms via an api.php file. I have gotten everything to work but redirecting to the pages I need them to once the post is successful.

Example code:

$.ajax({
    type: 'POST',
    url: 'Myapi.php',
    data: "method=updateMyPage&profileId="+profileId+"&recordId="+recordId,
    dataType: 'xml',
    success: function(xml){
        window.location="myPage.php";
    }
})

It works great for posting data, but gives me an xml response/page of success (set up in the api). Instead, I need it to redirect to the main page and show the updated data instead of the "success" page. I was able to re-code the api to do this for me but was instructed that was bad coding. So how do I get it to redirect on a successful post without changing the api? (also using SOAP if that matters)

If anyone can point me in the right direction it would be greatly appreciated :)

Upvotes: 2

Views: 4646

Answers (1)

Aaron
Aaron

Reputation: 5247

window.location should be window.location.href.

Upvotes: 4

Related Questions