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

json output

Daniel Hood

Well-known member
#1
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"
}
 

Jake Bunce

XenForo moderator
Staff member
#2
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.