Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Ajax post data not working

  • wilson31begijnendijk
  • wilson31begijnendijk's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago - 4 years 4 weeks ago #195566 by wilson31begijnendijk
Ajax post data not working was created by wilson31begijnendijk
Hi,

Is there any reason why this short test script should not work ?

It works fine if I skip the line [data:{test:"yeseys"},] but ofcourse I would like to post some data from the previous questions.

$.ajax({
method:'post',
url:'/AdminLTE/Limesurvey/test.php',
dataType: 'json',
data:{test:"yeseys"},
success:function(d) {
alert (d.doh);
}
});

Thanks for any input.
Frans
Last edit: 4 years 4 weeks ago by wilson31begijnendijk.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago #195585 by DenisChenu
Replied by DenisChenu on topic Ajax post data not working
Expression system check for {something}

Then to disable Expression add space (or new line

data:{
test:"yeseys"
},

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 4 weeks ago #195597 by Joffm
Replied by Joffm on topic Ajax post data not working
Hi, Frans,

I usually use this (without json):
Code:
$(document).on('ready pjax:scriptcomplete',function(){
 
  $.post('https://www.myServer.de/myFolder/getResult.php' , 
        {sid: "{SID}", age: "{Q1}",  gender: "{Q2}" } ,function(data) {
 
                   $('#question{QID} input[type="text"]').val(data);    //returned value
 
      });
//  $('#question{QID}').hide();
});

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • wilson31begijnendijk
  • wilson31begijnendijk's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 4 weeks ago #195598 by wilson31begijnendijk
Replied by wilson31begijnendijk on topic Ajax post data not working
Thank you !!!
Forgot the fact that curved brackets were used for reserved variables.

Got it to work now.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose