我提供了一个示例方案来帮助您入门:
<!-- Include this jQuery library in your HTML somewhere: --><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script
最好将其包含在外部JS文件中:
//Listen when a button, with a class of "myButton", is clicked//You can use any jQuery/Javascript event that you'd like to trigger the call$('.myButton').click(function() {//Send the AJAX call to the server $.ajax({ //The URL to process the request 'url' : 'page.php', //The type of request, also known as the "method" in HTML forms //Can be 'GET' or 'POST' 'type' : 'GET', //Any post-data/get-data parameters //This is optional 'data' : { 'paramater1' : 'value', 'parameter2' : 'another value' }, //The response from the server 'success' : function(data) { //You can use any jQuery/Javascript here!!! if (data == "success") { alert('request sent!'); } } });});


