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

Form sends _noRedirect=1 even when not using AJAX

Discussion in 'XenForo Development Discussions' started by Lior., Jul 1, 2013.

  1. Lior.

    Lior. Well-Known Member

    For some reason, even when sending the form through a regular page and not an overlay, _noRedirect is true, while it shouldn't be.

    I actually noticed this happens when sending a report too.

    Is there anything I can do to have _noRedirect turned off when not sending using AJAX?

    It's just that I'd like to have a JSON response for AJAX requests, and a redirect for regular requests, and this makes it impossible, as the controller can't tell what type of the request is.
  2. Chris D

    Chris D XenForo Developer Staff Member

    In the form element use the data-redirect="on" attribute. That should set noRedirect to false.
  3. Lior.

    Lior. Well-Known Member

    Unfortunately, that doesn't seem to work.
  4. Chris D

    Chris D XenForo Developer Staff Member

    Can you post the code you're using? Maybe there's something else.
  5. Lior.

    Lior. Well-Known Member

    No problem, though there's really not much to it:

    <xen:title>{xen:phrase user_reputation_give_reputation}</xen:title>
    <xen:h1>{xen:phrase user_reputation_give_reputation}</xen:h1>
        <xen:breadcrumb source="$nodeBreadCrumbs" />
        <xen:breadcrumb href="{xen:link full:posts, $post}">{xen:helper threadPrefix, $thread}{$thread.title}</xen:breadcrumb>
    <xen:container var="$bodyClasses">{xen:helper nodeClasses, $nodeBreadCrumbs, $forum}</xen:container>
    <xen:container var="$searchBar.thread"><xen:include template="search_bar_thread_only" /></xen:container>
    <xen:container var="$searchBar.forum"><xen:include template="search_bar_forum_only" /></xen:container>
    <form action="{xen:link 'posts/give-reputation', $post}" method="post" class="xenForm formOverlay AutoValidator GiveReputation" data-redirect="on">
        <dl class="ctrlUnit">
            <dt><label>{xen:phrase user_reputation_type}:</label></dt>
                    <li><label for="ctrl_positive"><input type="radio" name="type" id="ctrl_positive" value="1" checked="checked" /> {xen:phrase user_reputation_positive}</label></li>
                    <li><label for="ctrl_negative"><input type="radio" name="type" id="ctrl_negative" value="-1" /> {xen:phrase user_reputation_negative}</label></li>
            <dt><label for="ctrl_comment">{xen:phrase user_reputation_reputation_comment}:</label></dt>
            <dd><textarea name="comment" id="ctrl_comment" rows="2" class="textCtrl Elastic"></textarea></dd>
        <dl class="ctrlUnit submitUnit">
            <dd><input type="submit" value="{xen:phrase user_reputation_give_reputation}" accesskey="s" class="button primary" /></dd>
        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
        <input type="hidden" name="postId" value="{$post.post_id}" />
    Problem is that even when sending the from regularly, not through an overlay, _noRedirect is set to true.

    By the way, from what I can see, _noRedirect is set to true everywhere throughout XenForo,
    and for some reason there are places where it doesn't do a redirect when not using an overlay (like when reporting content), but in some place it does (like when replying).
    Last edited: Jul 1, 2013

Share This Page