Skip to content

Instantly share code, notes, and snippets.

@romreed
Created March 12, 2016 08:36
Show Gist options
  • Save romreed/58f00b57273a68c708cd to your computer and use it in GitHub Desktop.
Save romreed/58f00b57273a68c708cd to your computer and use it in GitHub Desktop.
Ajax
index.js
$('.Types').click(function(e) {
e.preventDefault();
/*var name = this.attr('name');
console.log(name);*/
$(this).addClass('active');
name=$('.active').attr('name');
$(this).removeClass('active');
data='type='+JSON.stringify(name);
$.ajax({
url:'http://reed.pe.hu/work1/preorder.php',
type:'post',
dataType:'json',
data:data,
success:function(data){
console.log(data);
},
error:function(data){
// console.log('bad');
},
complete:function(){
}
});
return false;
preorder.php
echo (json_decode($_POST["type"]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment