-
Hi all, I've read the following two discussions, but my case is slightly different from them. So far I have been writing a fixed completion code directly in the HTML file, but if participants check the source file they can easily find this out. Is there a way to hide the code? The code does not need to be different for each participant, it is fixed. Rather it should be fixed for my experiment. Do you have any ideas? If my PHP idea works, it would be very helpful if you could show me some sample code. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I've solved this problem by myself, but I'm not sure if this approach is correct. I made a very simple PHP file like this as getCompletionCode.php. <?php
echo '1234'; // This is the fixed code
?> The following code is written in the experiment file. let completion_code;
const getCode = {
type: jsPsychCallFunction,
async: true,
func: function(done){
console.log('getCompletionCode')
const xhr = new XMLHttpRequest();
xhr.open('POST', 'getCompletionCode.php');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if(xhr.status == 200){
completion_code = JSON.parse(xhr.responseText);
console.log(completion_code);
}
done(); // invoking done() causes experiment to progress to next trial.
};
xhr.send(null);
}
} I can receive the code and the code can not be probably seen from the source file. |
Beta Was this translation helpful? Give feedback.
I've solved this problem by myself, but I'm not sure if this approach is correct.
If you notice anything let me know.
I made a very simple PHP file like this as getCompletionCode.php.
The following code is written in the experiment file.