Add _xftoken to XenForo.ajax function

Marcus

Well-known member
This small template edit should display Watched Threads on every template it is copied. However I have to put in the xf_token, most likely at the second parameter in the XenForo.ajax request. Do you know how I could do that? Thanks !!
PHP:
<div id="watchedThreadsInline"></div>
<script>
	 		XenForo.ajax(
				'index.php?watched/threads',
				{},
				function(ajaxData,textStatus)
				{
					$('<li>function ajaxData,textStatus is executed</li>').xfInsert('appendTo', '#watchedThreadsInline');

					new XenForo.ExtLoader(ajaxData, function()
					{
						$(ajaxData.templateHtml).appendTo('#watchedThreadsInline');
					});
				}
			);
</script>[php]
 
This is my error message:

screenshot.webp
And this is the template edit
PHP:
<div id="watchedThreadsInline">
Should be replaced by WatchedThreads
</div>

<script>
             XenForo.ajax(
                'index.php?watched/threads',
                {},
                function(ajaxData,textStatus)
                {
                    $('<li>function ajaxData,textStatus is executed</li>').xfInsert('appendTo', '#watchedThreadsInline');

                    new XenForo.ExtLoader(ajaxData, function()
                    {
                        $(ajaxData.templateHtml).appendTo('#watchedThreadsInline');
                    });
                }
            );
</script>
 
Top Bottom