Created
December 16, 2013 20:55
-
-
Save dshaw002/7994249 to your computer and use it in GitHub Desktop.
Wordpress AJAX
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
//of your theme... | |
function test_ajax() | |
{ | |
$pass = "empty"; | |
if( isset( $_POST['passthrough'] ) ){ $pass = $_POST['passthrough']; } | |
die( json_encode( array("result"=>"true", "vars" => $pass) ) ); | |
} | |
add_action( 'wp_ajax_nopriv_test_ajax', 'test_ajax' ); // if user is not logged in | |
add_action( 'wp_ajax_test_ajax', 'test_ajax' ); //if user is logged in |
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
$('.deal-head-left').click(function(){ | |
$.ajax({ | |
url: 'http://162.243.11.26/wp-admin/admin-ajax.php', | |
type: 'POST', dataType: 'json', | |
data: { action: 'test_ajax', passthrough: 'Pass935JI'}, | |
success:function(data){ | |
console.log(data); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment