function winning (result) {
$.ajax(
{
url : "http://MYURL.com/api.php",
type: "POST",
data : result,
success: function(result)
{
msg ("Success!" + result.status)
}
,
error: function ()
{
msg ("Error!")
}
}
);
}
ty13r wrote:Currently seeing these errors in the console:
XMLHttpRequest cannot load http://MYURL.com/api.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'res://' is therefore not allowed access.
fb.js:15 Uncaught ReferenceError: ALSEvent is not defined
and
Uncaught ReferenceError: ALSEvent is not defined
function apiCall () {
var input = prompt ("enter code");
var inputObj = {'query' : input};
if (input != null) {
$.ajax({
type: 'POST',
dataType: 'text',
url: 'http://MYURL.com/api.php',
data: inputObj,
success: function (responseData, textStatus, jqXHR) {
if (responseData != "incorrect") {
$('#divOutput').html('<div>' + responseData + '</div>');
} else {
alert(responseData);
}
},
error: function (responseData, textStatus, errorThrown) {
alert('POST failed.');
}
});
} else {
alert('FAILBOAT')
}
}
The Pixie wrote:Good effort!
Can the Quest game determine if the right code was put in? I can see how the game will display whether it was successful of not; I cannot see how anything in the game world will know that however.
<?php
header('Access-Control-Allow-Origin: *');
$KEY = 'RANDOM STRING';
$ANSWER= 'RANDOM STRING';
$result = 'incorrect';
if (isset($_POST['query'])) {
$query = $_POST['query'];
$query_hash = hash('sha256', $query);
if ($query_hash == $KEY) {
$result = openssl_decrypt($ANSWER, 'aes256', $KEY);
}
}
echo $result;
The Pixie wrote:Have you tried the ASLEvent function in your JavaScript? If you have a function in Quest called SetResult that takes a string parameter, you should be able to call it like this:
ASLEvent ("SetResult", "correct");
ASLEvent ("SetResult", "wrong");