Issue with ajax user request in article with sourcerer.

kouros91

Member
Code:
{source}
<!-- You can place html anywhere within the source tags -->
<button id="reinitable" onClick="reinitable()";>R?initialiser les tables</button>

<script language="javascript" type="text/javascript">

function reinitable() {

var r = confirm("Voulez-vous vraiment r?initialiser les tables ?");

if (r == true) {

function retable (xxy) {
var url = "index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=reinitialisetables&idfiche=" + xxy;
new Request({url:url,
onComplete: function(response) {
if (response != '') {
alert(response);
}
}
}).send();
}

retable (1);

}

}

</script>
<?php
// You can place PHP like this

?>
{/source}
Hi.
I've created buttons in an article . They call userajax fabrik functions.
When it's in the article intro in a fabrik list loaded, it works . When i want to create an article alone with only my buttons and js code with sourcerer, without any list, . It doesn't work. UserAjax is not called.
When i put window.open(url,"_self"); instead of New Request .... , it works (without the response in a messagebox). It seems that function Request doesn't work with article alone.

Here is the erro message from console :

Uncaught TypeError: (intermediate value).send fonctions-superviseurs:222
at retable (fonctions-superviseurs:222)
at reinitable (fonctions-superviseurs:226)
at HTMLButtonElement.onclick (fonctions-superviseurs:196)

fonctions-superviseurs is the alias of my article.

How do i do ?

Thank you.
Nicolas
 
Last edited:
"Request" is a Mootools library call, and J! doesn't load Mootools, so it's only available on Fabrik pages.

You can use the jQuery equivalent (which we also use in our code, as we gradually migrate from Mootools to jQuery) ...

Code:
jQuery.ajax({
   url: url
}).done(function(response) {
   // your response code here
});

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top