Using AJAX in LimeSurvey questions

Plus d'informations
il y a 3 ans 7 mois #120495 par jembree
jembree a créé le sujet : Using AJAX in LimeSurvey questions
I'm trying to use an AJAX query inside of a survey question to draw in a bit of content. When I test the javascript outside of LimeSurvey, it works just fine; but when I try implementing it inside of a survey question, it fires off the ".fail()" status and reports an error.

Is there a particular trick to getting AJAX queries to work in LimeSurvey?

Here's a copy of the JavaScript code we're using:
<script>
$(document).ready(function() {
var thisTitle = "swls1";
var thisSid = "54558";
var thisLang = "en";
var ajaxUrl = " sardiprogram.com/vronline/limesurvey_ajax.php ";
$.get(ajaxUrl, { title:thisTitle, sid:thisSid, language:thisLang } )
.done(function(data) {
alert (data);
$("#put-it-here").html(data); // load form fields
})
.fail(function() { alert ('Still does not work');
});
});
</script>

This script is implemented outside of LimeSurvey and gets the results of its Ajax query here:
sardiprogram.com/vronline/kentest.php

But in this one question survey, it gets the "fail()" text alert instead of the success condition:
www.wittprojects.net/survey/index.php?r=...x/sid/638999/lang/en

Can anyone shed some light on what may cause this script to fail in a LimeSurvey context even though it works elsewhere?

Many thanks!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 ans 7 mois #120505 par tpartner
tpartner a répondu au sujet : Using AJAX in LimeSurvey questions
This is the problem - "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at sardiprogram.com/vronline/limesurvey_aja...id=54558&language=en . This can be fixed by moving the resource to the same domain or enabling CORS."

More info - dev.housetrip.com/2014/04/17/unleash-you...-requests-with-cors/


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Les utilisateur(s) suivant ont remercié: jembree

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!