Hello, I made a simple API for http://adf.ly/. Its using a simple code: <?php if($_POST['url'] == "") {$adfly = '';} else {$adfy = file_get_contents('http://api.adf.ly/api.php?key='.$_POST['key'].'&uid='.$_POST['uid'].'&advert_type='.$_POST['advert_type'].'&url='.$_POST['url'].'');} ?> <div style="width: 500px; height: 25px;"> <form action="" method="POST"> URL: <input type="text" name="url" value="<?php echo $adfy; ?>" autocomplete="off" style="width: 415px;"><input type="submit" value="GO!" /> <input type="hidden" name="key" value="4bcda350fa20bf2df323234bb7ef5282" /> <input type="hidden" name="uid" value="95917" /> <input type="hidden" name="advert_type" value="int" /> </form> </div> PHP: But i want to add some Ajax and jQuery to it so the page doesn't need to get reload fully. Thanks,
Here you go : <?php if(isset($_GET['key']) && $_GET['key'] != "" && isset($_GET['uid']) && $_GET['uid'] != "" && isset($_GET['advert_type']) && $_GET['advert_type'] != "" && isset($_GET['url']) && $_GET['url'] != "") { echo file_get_contents('http://api.adf.ly/api.php?key='.$_GET['key'].'&uid='.$_GET['uid'].'&advert_type='.$_GET['advert_type'].'&url='.$_GET['url']); } else { ?> <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#go').click(function(){ var key = $('#key').val(); var uid = $('#uid').val(); var advert_type = $('#advert_type').val(); var url = $('#url').val(); if(url.length > 0) { $('#result').load('adf.php?key='+key+'&uid='+uid+'&advert_type='+advert_type+'&url='+escape(url));* } else { $('#result').html('<font style="color : red;">You must enter an url !</font>'); } }); }); </script> </head> <body> <div style="width: 500px; height: 25px;"> URL: <input type="text" id="url" name="url" value="" autocomplete="off" style="width: 415px;" /><input type="button" id="go" value="GO!" /> <input type="hidden" id="key" name="key" value="4bcda350fa20bf2df323234bb7ef5282" /> <input type="hidden" id="uid" name="uid" value="95917" /> <input type="hidden" id="advert_type" name="advert_type" value="int" /> </div> <div id="result"></div> </body> </html> <?php } ?> PHP: