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

Add _xftoken to XenForo.ajax function

Marcus

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

Marcus

Well-known member
#3
This is my error message:

screenshot.png
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>