I may be missing something obvious but i have a problem with browser redirects i cant seem to resolve. Before delving into custom php to solve this I thought I would ask here
I know is is simple to redirect conditionally with an expression like browser1.goto( [condition]?’‘page1.html’:‘page2.html’) within the success event.
In my case the server action returns a status code between 0 and 4
what i need is to ignore status codes 0-2 (i.e no redirect) but redirect to “page3.html” and ‘page4.html’ on status codes 3 or 4.
I am running out of ideas, everything i have tried either causes an error or redirects incorrectly
Anyone any ideas?
Teodor
January 11, 2020, 12:05pm
2
Hi Brian,
Please try:
browser1.goto( status == 3 ? 'page3.html' : status == 4 ? 'page4.html' : false)
Not sure about the ‘false’ part as I am on my phone currently.
Interesting. needed “F” of false capitalised i.e. “False” but it does work thanks
It does however leave an error in the developers console when the “False” is called i.e. stutus’ 0 - 2
Teodor
January 11, 2020, 12:38pm
4
Ok, sorry what if you try ''
instead of 'false'
I will be able to check this but later, when I am on a computer.
That was my first idea, unfortunately that redirects to the website root
Teodor
January 11, 2020, 12:56pm
6
Maybe just change the condition logic, like:
status == 3 ? browser1.goto('page3.html') : status == 4 ? browser1.goto('page4.html') : false
Thanks Teodor, that has done it!
2 Likes
t11
February 11, 2020, 11:07am
8
Hello I am having an issue with that. Trying to implement it like this.
<dmx-serverconnect id="check_service" url="dmxConnect/api/surveys/2020/compare.aspx" dmx-param:sid="query.id" dmx-on:success="status==271 ? browser1.goto('https://www.mysite.com') : false"></dmx-serverconnect>
But this won’t execute because I think I am setting the status to 271 and the success (200 status) would trigger the conditional.
Teodor
February 11, 2020, 11:08am
9
So what are you trying to do, Niko?
t11
February 11, 2020, 11:11am
10
If the query does not return anything I am setting status==271. This works fine.
I just can’t get it to trigger the browser redirection
Teodor
February 11, 2020, 11:12am
11
If the status is 271 - then your condition should work. Can you please provide a link where i can check this?
t11
February 11, 2020, 11:13am
12
Its local… let me check if I am missing something else
Teodor
February 11, 2020, 11:14am
13
Please check your browser console first. Probably some include is missing.
t11
February 11, 2020, 11:20am
14
This is what it gets returned regarding status
Teodor
February 11, 2020, 11:21am
15
Please check the console for errors/warnings Niko …
t11
February 11, 2020, 11:21am
16
Yes I did… let me recheck
t11
February 11, 2020, 11:26am
17
The only warnings that I get in the console is
DevTools failed to parse SourceMap: http://localhost/bootstrap/4/js/popper.min.js.map
DevTools failed to parse SourceMap: http://localhost/bootstrap/4/js/bootstrap.min.js.map
DevTools failed to parse SourceMap: http://localhost/bootstrap/4/css/bootstrap.min.css.map
DevTools failed to parse SourceMap: http://localhost/bootstrap/4/js/popper.min.js.map
Teodor
February 11, 2020, 11:28am
18
These are not related.
I need a link to your page where i can test this.
t11
February 11, 2020, 11:30am
19
Yes don’t worry Teo. Just needed to confirm that the condition should be working. I will figure it out. Thank you!!!
Teodor
February 11, 2020, 11:32am
20
Hm, i notice your redirect is added onsuccess event … onsuccess means status 200.
Change it to ondone.
1 Like