Welcome to the LimeSurvey Community Forum

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

Implement "AJAX"-call

  • king_and1
  • king_and1's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 11 months ago #95327 by king_and1
Implement "AJAX"-call was created by king_and1
Well , so i got the Blue and Gray template where i changed some colors and so on....

The structure still the same.

The first question in my Survey is like : "please type in your serial number"

Well, and thats exactly where i want an Ajax call. After the user finished the input, it should start checking the serial number on a external server and provide an answer if this serial is correct or not .
I´ve searched the question.pstpl(dunno how its correct..) and i´ve found the div_class="answers" and the table´s in it. But i dont know how to specifically target this first question. So i hope this is enough information so we can go on working out this problem , if not please tell me what´s missing and i´m gonna try editing it as good as possible...
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 11 months ago #95334 by tpartner
Replied by tpartner on topic Implement "AJAX"-call
I've moved this post to a more appropriate category. And, please don't cross post.

You would place the JavaScript for the AJAX call in the source of the question. See - manual.limesurvey.org/Workarounds:_Manip....29_in_LimeSurvey.3F

So, if you are using the jQuery get() function, the JS would look something like:
Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    var qID = {QID};
 
    $('#question'+qID+' input[type="text"]').change(function(){
      $.get('http://somedomain.com/customScript.php', { serial: $('#question'+qID+' input[type="text"]').val() } );
    });
  });
</script>

Unfortunately, I can't help you with the PHP coding.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose