通过PHP从ajax访问MySQL数据库

I'm trying to write a simple function where ajax sends parameters to PHP service and then PHP requests MySQL for data and sends result to ajax function.I dont have much idea about AJAX. Can anybody suggest sample code or links.

For the basics without using a framework, see http://www.w3schools.com/ajax/default.asp

I'd recommend using a JS Library such as jQuery, as this can hugely simplify your code.

Check out how jQuery implements ajax here - http://api.jquery.com/jQuery.ajax/

I would try jQuery, try this code snippet:

//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' : 'POST',
  //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!');
      }
    }
  });
});

Hope that helps,
spryno724