tenants
Well-known member
For some plugins, you might want to do things silently with JavaScript (for things that don't entirely matter when they are complete, but you don't want to bother the users), but there is no way to do this and still use the XenForo ViewPublic and only send back the json response
Using XenForo.ajax will always initiate the XenForo #AjaxProgress loading icon
Using the _xfResponseType: "json" is required to be able to use the ViewPublic and only send back the json response, but as soon as we use _xfResponseType: "json", we see the XenForo #AjaxProgress icon
All we would need is an extra param in XenForo ajax that would be set to true by default, but we could set to false:
XenForo.ajax(string url, array params, boolen displayProgress=true)
Code:
XenForo.ajax("someurl'", {someparam:"{$someparam}}, function(ajaxData, textStatus)
{
if(textStatus == "success"){alert.("success");}
})
Code:
<script>
var sendData = {
_xfResponseType: "json",
_xfToken: "{$visitor.csrf_token_page}"
};
$.ajax({
type: "POST",
url: "{xen:link myplugin/here}",
data: sendData,
dataType: "json",
headers: {'X-Ajax-Referer': window.location.href},
timeout: 30000, // 30s
success: function (ajaxData, textStatus) {},
});
</script>
All we would need is an extra param in XenForo ajax that would be set to true by default, but we could set to false:
XenForo.ajax(string url, array params, boolen displayProgress=true)
Last edited:
Upvote
1