Jump to content
Sign in to follow this  

License Validate Via jsonp

Recommended Posts

I'm trying to create an ajax call using jQuery jsonp. I'm fairly new jQuery and jsonp (trying out some examples to learn), however i'm very keen to learn how to build a javascript file to include into future project that will validate a license code. 

I'm come up with the following code: 


<script type="text/javascript" src="http://www.example.co.uk/javascript/jquery/jquery-1.7.1.min.js"></script>
<script type="application/javascript">
(function($) {
    var licensing = function() {
		var domain = 'test.com';
		var EID = 'EXT123';
		var LC = '1234';
             type : "GET",
             dataType : "jsonp",
             contentType: "application/json",
             jsonpCallback: "resp",
             url : "//example.com/license/index.php?domain="+ domain +"&licenseCode="+ LC +"&EID="+ EID +"",
             success: function(response) {
             error: function() {
                alert('An error occurred during validation. Please try again. If the issue persists, contact support.');

However I'm struggling to find suitable examples for the next stage which would be the PHP file example.com/license/index.php which I would like to handle the parameters passed, check the database and create an array named response to hold all the information pulled from the database. 

I'm fine with connecting to the database, building the array etc but I'm not too sure where to start in regards to accepting the call, I'm tried this simple code for now:



$domain = $_GET['domain'];
$licenseCode = $_GET['licenseCode'];
$EID = $_GET['EID'];

echo $domain . " " . $licenseCode . " " . $EID . " ";

But It's throwing the error as the AJAX has failed. 

Does anyone have any good examples of what would need to include the in PHP file to handle the request? 


Share this post

Link to post
Share on other sites

This is not how JSONP works.


Why did you choose it, anyway? JSONP is a horrendously insecure legacy hack. Unless you specifically need to support ancient browsers, use CORS instead.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.