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

json output

Discussion in 'XenForo Development Discussions' started by Daniel Hood, Jun 2, 2013.

  1. Daniel Hood

    Daniel Hood Well-Known Member

    I'm working on something and want to have ajax requests. I know that you can just add .json to any url and it sets the output method as json. But currently I get this response:

    Code:
    {
    error: [
    "Security error occurred. Please press back, refresh the page, and try again."
    ],
    templateHtml: " <div class="errorOverlay"> <a class="close OverlayCloser"></a> <h2 class="heading">The following error occurred:</h2> <div class="baseHtml"> <label for="ctrl_0" class="OverlayCloser">Security error occurred. Please press back, refresh the page, and try again.</label> </div> </div>",
    _visitor_conversationsUnread: "0",
    _visitor_alertsUnread: "0"
    }
    
    How can I make that stop erroring and output:
    Code:
    myArray: {
    }
    
    instead of
    Code:
    {
    templateHtml: "",
    _visitor_conversationsUnread: "0",
    _visitor_alertsUnread: "0"
    }
    
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    All POST and JSON requests require a token unless excepted. You may wish to make an exception for your action by extending the _checkCsrf function in your controller. Otherwise make sure the token is present in your request.
     
    Daniel Hood likes this.
  3. Daniel Hood

    Daniel Hood Well-Known Member

    Thanks.
     

Share This Page