Jump to content

License Validate Via jsonp


Orionsbelter

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';
		
        $.ajax({
             type : "GET",
             dataType : "jsonp",
             jsonp:"callback",
             contentType: "application/json",
             jsonpCallback: "resp",
             url : "//example.com/license/index.php?domain="+ domain +"&licenseCode="+ LC +"&EID="+ EID +"",
             success: function(response) {
		alert(response)
             },
             error: function() {
                alert('An error occurred during validation. Please try again. If the issue persists, contact support.');
             }
        });
    
    }
        
    licensing(null);
})(jQuery)
</script>

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:

 

<?php 

$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? 

Thanks. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.

×
×
  • 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.