Created
February 7, 2017 13:43
-
-
Save tgaraptor/a5dc4a0ab9adfcd41e79584e3e225ece to your computer and use it in GitHub Desktop.
Non-blocking async raptor request using ajax and php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | |
</head> | |
<body> | |
<div id="output"></div> | |
<script type="text/javascript"> | |
var moduleName ="GetOverAllTopVisits"; //See the Raptor Controlpanel for All available modules | |
callRaptor(moduleName,10); | |
function callRaptor( moduleName,numberOfRecommendations) { | |
$.ajax({ | |
url:'callRaptor.php', | |
data:{ | |
moduleName: moduleName, | |
numberOfRecommendations: numberOfRecommendations | |
}, | |
complete: function (response) { | |
var json = response.responseText; | |
$('#output').html(response.responseText); | |
//Render products | |
}, | |
error: function (error) { | |
$('#output').html(error); | |
//Log Error | |
//Return Fallback | |
} | |
}); | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment