Using AJAX in LimeSurvey questions

4 years 1 month ago #120495 by jembree
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:
$(document).ready(function() {
var thisTitle = "swls1";
var thisSid = "54558";
var thisLang = "en";
var ajaxUrl = " ";
$.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');

This script is implemented outside of LimeSurvey and gets the results of its Ajax query here:

But in this one question survey, it gets the "fail()" text alert instead of the success condition:

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

Many thanks!

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
4 years 1 month ago #120505 by tpartner
This is the problem - "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at . This can be fixed by moving the resource to the same domain or enabling CORS."

More info -


Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Official LimeSurvey Partner -
The following user(s) said Thank You: jembree

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!