Jquery Ajax

var ajaxUrl = "phpfile.php";
            $("#buttonAjax").click(function () {
                $("#divAjax").html(ajax_load);

                $.ajax({
                    type: "GET", 		//GET or POST or PUT or DELETE verb
                    url: ajaxUrl, 		// Location of the service
                    data: {key:value,key1:value1}, 		//Data sent to server
                    Type: "POST",		// content type sent to server
                    dataType: "html", 	//Expected data format from server (html/json)
                    processdata: true, 	//True or False
                    success: function (result) {//On Successful service call
                        $("#dvAjax").html(result);
                    },
                    error: ServiceFailed	// When Service call fails
                });

                return false;
            });
//in php file (phpfile.php)
<?php
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')){
//perform functionality
}
?>


			

Leave a Reply

Your email address will not be published. Required fields are marked *