Trouble with form return message

  • Thread starter Thread starter account8226
  • Start date Start date
A

account8226

Guest
Hello,

I am having trouble with my forms, I have an action, and data-fieldValidatorUrl, with data-redirect on off.

When I submit my form :

If there is an error, it's working fine, a nice XenForo's error popup is showing up with the following code :
PHP:
$this->responseError(new XenForo_Phrase('error'));

But when everything goes fine, I would like the page to refresh, but it's actually returning a javascript error, here is the result with firebug :
PHP ?> {"status":"ok","message":" [........]

Here is the final return code :
PHP:
$redirectUrl = XenForo_Link::buildPublicLink('my_link');
       
        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            $redirectUrl,
            new XenForo_Phrase('my_text')
        );


How can I return a simple message as a popup for example ? That would say everything was fine, do I have to use javascript ?

Regards.
 
You're doing it the right way.

On your form element in the template ensure you have "AutoValidator" as one of the class names and have data-redirect="on" as an attribute on the form too.
 
You're doing it the right way.

On your form element in the template ensure you have "AutoValidator" as one of the class names and have data-redirect="on" as an attribute on the form too.

Hey thanks for the reply,

My problem is that I have everything like you said, like the AutoValidator or data redirect tag, but it's throwing a JS error :
error.webp

The JS error message is above on post #1.
 
Is that all that's in the console? Doesn't look like an error to me.

Just a thought: Make sure you've not got anything that could modify the output of the form action...

e.g. If you have anything like echo, or var_dump or Zend_Debug::dump then it may very well generate an error (as it breaks the json output).

Aside from that, a javascript error message can come up due to some other reason. Check closely for syntax errors etc.
 
Check out this :
redirect.webp

It it's the Javascript Console (error).

Don't you think that ?> is strange at the begining ?
 
hm actually, yeah that doesn't quite look correct.

As I say, you've probably got a boo boo in your code - whatever code is running when the form is submitted.

Possibly even a missing close bracket }
 
Is that all that's in the console? Doesn't look like an error to me.

Just a thought: Make sure you've not got anything that could modify the output of the form action...

e.g. If you have anything like echo, or var_dump or Zend_Debug::dump then it may very well generate an error (as it breaks the json output).

Aside from that, a javascript error message can come up due to some other reason. Check closely for syntax errors etc.

Lol ;)

cb48803a6b9b8e2a6f96a88f4f590b07.webp

epic_fail2.webp

Thanks for the help Chris :)
 
Top Bottom