Kasarn Doungprateep
Posts: 0
Joined: Wed Dec 11, 2013 12:49 pm

Using Ajax to post and then redirect

I want to use method 'post' on "https://www.example.com", and then redirect to another page. Like this,

$.ajax({
type: "post",
url: "https://www.example.com",
success: function() { $(location).attr('href','page2.html'); }
});

It seems like the post process works fine.

However, the redirect process ( in success section ) does not work.

Where do I miss about this?

Thank you

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Using Ajax to post and then redirect

Hello,

Please try to use
codeAppery.navigateTo('page2', {});/code in success function.
http://docs.appery.io/javascript-api/...

Kasarn Doungprateep
Posts: 0
Joined: Wed Dec 11, 2013 12:49 pm

Using Ajax to post and then redirect

Thank you.

It is working now.

But could you please tell me why ?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Using Ajax to post and then redirect

Hello! Code pre$(location).attr('href','page2.html'); /pre is not correct because location is not DOM element. You can't make it $(location) and refer to href attribute, because it doesn't have attribute. It's object which has property. You can do for example this way prewindow.location.href = 'page2.html';/pre

Return to “Issues”