javascript - Rails redirect_to after jquery $.post -


Why can not my browser go to a new page when I submit it?

I think there is a button that posts and functions data in my controller.

My coffee script:

  $ Post "/ token / create", Json   

create tokens controller #

  redirect_to root_path, notice: 'parser successfully created I went.'   

log file looks like this works:

  to get started / "create / token / 2014" Make 127.0.0.1 -10-08 10:27:39 -0400 as processing by * TokenController # * ... as found in http: // localhost: 3000 / full 302 in 372 (active record: 10.0ms) "/" For 127.0.0.1 2014-10-08 10:27:40 -0400 by Visitors Controller as processing # index * / * ... In 2009 complete OK 2891ms (view: 2886.6ms | ActiveRecord: 3.0ms)   

but the page I'm on can not change Is obtained. On which page do I specify the page in the "redirect_to" row, how do I create it?

You can do the following:

  def = # Do some things if request.xhr? # If the test is an AJAX call render JS: "document.location = '# {root_path}'" else redirect_to root_path, notice: 'the parser was created successfully.' End   

Do you want to use flash in AJAX cases too? Check this answer: (and well, give your answer if it helps you)

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -