On Tuesday, December 2, 2014 at 3:45:52 AM UTC-8, Russell Dunphy wrote:
> I'm trying to get my head around structuring my client-side routes (in a 
> reagent app) using secretary, and I'm struggling to work out the best way of 
> dealing with the "redirect-after-post" scenario where I have a form that is 
> submitted via AJAX, and once the AJAX request has successfully completed, I 
> want to change to a different page to view the saved record.
> 
> The two ways I can think of to achieve this are:
> 
> 1. Have the on-click event of the submit button make the ajax request, and 
> have the success handler call secretary/dispatch! to the new page.
> 
> This has the disadvantage of not changing the url hash, so links back to the 
> form don't work until you've changed pages again normally.
> 
> 2. Replace the submit button with an anchor tag pointing at a different 
> secretary route, something like /my-model/create, which makes the POST 
> request and renders the new page. The problem with this approach is that you 
> have to get the form data to the secretary route somehow, either by having it 
> as params on the URL, which seems a bit pants, or by having it in a state 
> atom that both the form and the secretary route knows about (which seems like 
> data that shouldn't be shared).
> 
> How are other people doing this? Am I on completely the wrong track?
> 
> Thanks,
> 
> Russell

Hi Russell,

Have you got this problem solved?  ( I would think you have as it is long time 
back.).  Would you mind posting your resolution here?  Thanks in advance.  I am 
facing a similar issue here.

The response to curl is as follows:

HTTP/1.1 302 Found
Server: undertow
X-XSS-Protection: 1; mode=block
Location: http://localhost:3000/login  <---------
X-Frame-Options: SAMEORIGIN
Date: Fri, 11 Sep 2015 21:06:28 GMT
Connection: keep-alive
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8  <----------------
Content-Length: 0

However, the reagent form is not getting redirected to he /login form.  It 
remains in the same form.  On the console, I can see, however, the login page 
is streamed as an HTML. ( I am using "/login" as just as an example.).

The original reagent page is doing a request with CLJS-AJAX POST.

Any hint is much appreciated.  Thanks,

Regards,
Hari

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to