Page 1 of 1

Using Ajax to post and then redirect

Posted: Tue Jan 28, 2014 10:36 pm
by Kasarn Doungprateep

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


Using Ajax to post and then redirect

Posted: Tue Jan 28, 2014 11:59 pm
by Igor

Hello,

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


Using Ajax to post and then redirect

Posted: Wed Jan 29, 2014 12:16 am
by Kasarn Doungprateep

Thank you.

It is working now.

But could you please tell me why ?


Using Ajax to post and then redirect

Posted: Wed Jan 29, 2014 10:21 am
by Maryna Brodina

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