[
https://issues.apache.org/jira/browse/JSPWIKI-1195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17866184#comment-17866184
]
Dirk Frederickx commented on JSPWIKI-1195:
------------------------------------------
The ajaxHtmlCall used by the SampleAjaxPlugin is based on an older
jspwiki-common.js implementation, and is not supported in the current version.
Instead you need to be using the Request() object of mootools.
Old:
{code:javascript}
Wiki.ajaxHtmlCall(url, [12,45], 'result'+id, 'Loading….');
{code}
Replace by:
{code:javascript}
$(‘result’+id).value=‘Loading…’;
new Request.HTML({
url: Wiki.JsonUrl + url,
data: {params: [12,45] , 'X-XSRF-TOKEN': Wiki.CsrfProtection},
update:$(‘result'+id),
//these 2 lines only for debugging
onSuccess: function(data){console.log('Success',data);},
onError: function(err){console.log('Error',err);}
}).send()
{code}
This should be inserted in the generated HTML code:
{code:html}
<div onclick=‘ —the-js-comes-here— ' style='color: blue; cursor:
pointer'>Press Me</div>
<div id='result"+id+"'></div>
{code}
Alternatively, you could use in modern browsers the native fetch API.
Something like this:
{code:javascript}
document.getElementById('result'+id).textContent = 'Loading…';
fetch(Wiki.JsonUrl + url, {
body: JSON.stringify({params: [12,45] , 'X-XSRF-TOKEN':
Wiki.CsrfProtection})
}).then(response => document.getElementById('result'+id).textContent =
response);
{code}
dirk
> jspwiki-common.js not included in page, breaking AJAX functionality
> -------------------------------------------------------------------
>
> Key: JSPWIKI-1195
> URL: https://issues.apache.org/jira/browse/JSPWIKI-1195
> Project: JSPWiki
> Issue Type: Bug
> Components: Templates and UI
> Affects Versions: 2.12.2
> Reporter: Ulf Dittmer
> Priority: Minor
>
> The [https://jspwiki-wiki.apache.org/Wiki.jsp?page=SampleAjaxPlugin] plugin
> is currently broken, because the jspwiki-common.js file (which defines the
> Wiki.ajaxHtmlCall function) that it depends on is not included in the page.
> Likely culprit are missing lines
> <script src="<wiki:Link format='url' jsp='scripts/haddock.js'/>"></script>
> <script src="<wiki:Link format='url' jsp='scripts/mootools.js'/>"></script>
> in
> [jspwiki-war|https://github.com/apache/jspwiki/tree/31f539a1fdadc0401af70bb39732c110e128eaea/jspwiki-war]/src/main/webapp/default/commonheader.jsp
> but simply adding those causes further JavaScript errors.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)