-
-
Save AngeloR/1672212 to your computer and use it in GitHub Desktop.
Jbom - pastebin.com/uEEvZEpK
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
//JAVASCRIPT | |
$(document).ready(function(){ | |
CLICKIT_core.init(); | |
CLICKIT_contract_form.init(); | |
}); | |
var CLICKIT_config = { | |
URLs : { | |
checkName : 'index.php/users/getnames' | |
} | |
} | |
var CLICKIT_ajax = { | |
checkName : function (name,callback){ | |
$.ajax({ | |
url: CLICKIT_config.URLs.checkName, | |
type: "POST", | |
async: true, | |
data: "name="+name, | |
dataType:"json", | |
success: function (data){ | |
callback(data); | |
} | |
}); | |
} | |
} | |
var CLICKIT_contract_form={ | |
init:function(){ | |
//Submit Event | |
$('#contract form#check_name').bind('submit',function(){ | |
CLICKIT_contract_form.onSubmit(); | |
return false; | |
}); | |
}, | |
onSubmit:function(){ | |
var name = $('#contract form#check_name input[id="url"]').val(); | |
if($.trim(name) != ""){ | |
$('#contract form#check_name button span').addClass('loading'); | |
$('#contract form#check_name button span').html('cargando'); | |
CLICKIT_ajax.checkName(name,CLICKIT_contract_form.onReceive); | |
} | |
}, | |
onReceive:function(data){ | |
//myJson = eval("(" + data + ");"); | |
$('#contract form#check_name button span').html('FIN'); | |
//console.log(data.name); | |
console.log(data.result); | |
} | |
} | |
------------------------------------------------------ | |
------------------------------------------------------ | |
//PHP | |
public function getnames(){ | |
$jsondata['name'] = $_POST['name']; | |
$jsondata['result'] = 'ok'; | |
header('Content-type: application/json'); | |
echo json_encode($jsondata); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment