Teka Teka - 1 year ago 33
HTML Question

How to post data to php file and get result using ajax?

Hi I want to post data to php and reseve php result and result post to html div tag. Please give me sample code. Thank you sorry for my bad English


Okay, suppose you can to make an AJAX request when clicked to an a tag with class link, HTML looks like:

<div class="content"></div>
<a href="#" class="link">Ajax Request</a>


        method: 'GET',  
        url: 'ajax.php',
        data: { 'data_id': 'YOUR_DATA' }, //Data you want to send
        success: function(response) {


//Do some process and echo what you want to sendback
echo $data; 

Note: Your must include jQuery in your document