• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

The server responded with an error. The error message is in the JavaScript console.

localhost8080

Well-known member
#1
Hi friends of this nice peace of bugware.

Sometimes I wish I had never moved from phpbb to this stuff. But who cares.

I do some simple stupid form stuff and send it to my class.

Like a textbox where a user enters his name and I respond his name back from my class.

But, instead of displaying the response, I get

The server responded with an error. The error message is in the JavaScript console.
When I look in my console, I see the correct modified stuff from my method in json format but the page content doesn't change except that nice error overlay.

wtf?

I have a simple form in my template:

HTML:
<form action="/pages/Testpage1" method="get" class="xenForm AutoValidator" data-redirect="on">
    Your Location: <input name="form_location" type="text" value="{$visitor.location}" class="textCtrl autoSize" maxlength="5" size="5" />
    &nbsp;&nbsp;&nbsp;
    <input type="submit" value="submit your entry" class="button primary" />
</form>
and a callback class method that is being called on form submit:

PHP:
    public static function getThreads(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract $response)
    {
        $loc = (int)$controller->getInput()->filterSingle('form_location', XenForo_Input::STRING);

        var_dump("YOUR LOC IS: " . $loc);
     
            $threadIds = array();

        $threads = $threadModel->getThreadsByIds(
            $threadIds,
            array(
                'join' =>
                    XenForo_Model_Thread::FETCH_FORUM |
                    XenForo_Model_Thread::FETCH_USER,
                'permissionCombinationId' => $visitor['permission_combination_id'],
                'order' => 'post_date',
                'orderDirection' => 'desc'
            )
        );
     
        $response->params['threads'] = $threads;
        $response->templateName = 'thread_list_modified';
     
    }
in the js console I see the output of the var_dump from my method...

some one got a hint what's going wrong here?

thank you.
 

localhost8080

Well-known member
#5
this doesn't help. Still unspecified error. On first page call, content is generated by the same method.

This problem only occurs if I submit that form...
 

localhost8080

Well-known member
#7
Okay, thank you. I will try it tomorrow with simple code and give you response.

Or, I send you my code by pn tomorrow and send you some bottles of best bavarian beer if you fix it. ;-)
 

Lawrence

Well-known member
#8
From your form action, you are using a Page Node. The callback for your Page Node should be used to generate the data you want displayed on that page (calls the templateName with the form in it).

Your form action should point to a controller public class to read the form data when submitted, ie:
<form action="{xen:link 'page/dosomething'}"

PHP:
class Your_ControllerPublic_Page extends XenForo_ControllerPublic_Abstract
{
    public function actionDoSomething()
    {
      $loc = (int)$controller->getInput()->filterSingle('form_location', XenForo_Input::STRING);
      // process your input and save it and then return a responseView or a responseRedirect
   }
}
 

Lawrence

Well-known member
#10
I think the problem is AutoValidator classes. Just try to remove the class maybe help.
I use the autoValidator class for the form I use for my page node and it causes no problems, as it receives the responseRedirect message sent from the public controller:

HTML:
<form name="traininghall" id="traininghall" action="{xen:link 'traininghall/next'}" method="post" class="xenForm AutoValidator" data-redirect="on">
PHP:
        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            XenForo_Link::buildPublicLink('pages/training-hall'),
            $charSavedResponse
        );
 

localhost8080

Well-known member
#12
Ok. I have got my add on, route prefix, public controller.

My page node gets data from callback class and contsins a form.

After submiting the form my variables comes until controller.

Now, how do i push them to my callback class and rebuild the page node?
 

localhost8080

Well-known member
#16
no, surely not. but if you pay year by year for two licences and even don't get answers for simple questions like how to handle data from a custom form, I ask you where's the support and why do you call this "customer area"?
 

Brogan

XenForo moderator
Staff member
#17
The forum is for community support, which you aren't paying for.

You pay for ticket support, which will guarantee a response from a XenForo staff member.

Ticket support however isn't for custom development, styling, modification, etc.

Bear in mind that all responses on the forum are by people using their spare time of their own accord, for free.