Welcome to the LimeSurvey Community Forum

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

jquery open dialog with php external source

  • marcomarenco
  • marcomarenco's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 3 weeks ago #149219 by marcomarenco
jquery open dialog with php external source was created by marcomarenco
Hi,
i've added a button in the admin question page, i'm trying to load an external php file, it seems that is not possible.
i use this code in editQuestion_view.php:
<script>
$("#load_anagram").click(function () {
$('#dialog_anagram_load').load('test.php').dialog('open');
});



$( "#dialog_anagram_load" ).dialog({
autoOpen: false,
height:500,
width:600,
show: {
effect: "blind",
duration: 1000
},
resizable: false,
hide: {
effect: "explode",
duration: 1000
},
position: { my: 'top', at: 'top+50' },
});
</script>

the file exists, but it load another page, the message is:
Error
Invalid question id

i don't have any idea which file it use. could you help me?

thanks
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 weeks ago #149221 by holch
As far as I know, Limesurvey does not allow to load non-LS PHP files because of security reasons.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • marcomarenco
  • marcomarenco's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 weeks ago #149231 by marcomarenco
Replied by marcomarenco on topic jquery open dialog with php external source
yes, i think that you're in right. maybe a solution is to embed the code inside editQuestion_view.php?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 weeks ago #149258 by tpartner
Replied by tpartner on topic jquery open dialog with php external source
You can use jQuery .load() with PHP files but it will only load the returned HTML of the file - api.jquery.com/load/

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • marcomarenco
  • marcomarenco's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 weeks ago #149268 by marcomarenco
Replied by marcomarenco on topic jquery open dialog with php external source
hi,
i would use .ajax, but it's not possible.
now i've the same problem with .autocomplete :(

bye
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 2 weeks ago #149274 by tpartner
Replied by tpartner on topic jquery open dialog with php external source
Why is it not possible? Where are you placing the JavaScript? Do you have any errors in the console?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • marcomarenco
  • marcomarenco's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 weeks ago #149278 by marcomarenco
Replied by marcomarenco on topic jquery open dialog with php external source
i've put the code inside the file: editQuestion_view.php (in limesurvey\application\views\admin\survey\Question)

here is the script:
$("#parolaauto")
.on( "keydown", function( event ) {

if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).autocomplete( "instance" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
source: function( request, response) {
$.ajax({
url: "searchanagramletter.php",
dataType: "json",
data: {
term: request.term,
nsillabe: $('#nsillabe option:selected').val(),
nchar: $('#nchar option:selected').val(),
n_anagrammi: $('#n_anagrammi option:selected').val()



},
success: function( data ) {
response( data );
}
});
},
minLength: 0,
autoFocus:true,
response: function (event, ui) {
var len = ui.content.length;

if (len<1)
{
$('#parolaauto').val('');
$('#num_parole').val('0');
}
else
{
$('#num_parole').val(len);
}

},
select: function( event, ui ) {
//alert(JSON.stringify(ui.item))
log( ui.item.label, ui.item.letter, ui.item.nsillabe, ui.item.nchar, ui.item.n_anagrammi, ui.item.anagrammi);
}
});

i've tried the script in a stand alone application and i don't have any problem, in limesurvey, there's something regarding token control: YII_CSRF_TOKEN
but i'm not sure, maybe there's a control to check the integrity of file, or if the file is a "limesurey file", i've noticed that when i call the script (for autcomplete, and before for load the page in a dialog) some code is append to my request:

GET searchanagramletter.php?YII_CSRF_TOKEN=84ee15c94793409919f931a13e06f0c004d9ec20&term=abar&nsillabe=
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose