Ajax is a very popular way to load the content without refresh the page . Ajax is a way to connect your application with the server in the back-end . Some times we need to use ajax in multiple places . So instead of creating ajax method on all places we can define a common metod and use the return data on other places . for this we’ll define a method like given below.

function ajaxcall(url, data, callback) {
    $.ajax({
        url: url, // server url
        type: 'POST', //POST or GET 
        data: data, // data to send in ajax format or querystring format
        datatype: 'json',
        beforeSend: function() {
            alert('sending data');
            // do some loading options
        },
        success: function(data) {
            callback(data); // return data in callback
        },

        complete: function() {
            alert('ajax call complete');
            // success alerts
        },

        error: function(xhr, status, error) {
            alert(xhr.responseText); // error occur 
        }

    });
}

Now we have a common method for ajax and ready to use.


$(document).on('click', ".someelement", function(e) {
    e.preventDefault();
    ajaxcall('someurl.php', {
        key: 'value',
        key2: 'value2'
    }, function(output) {
        alert(output);
    });
}) 
http://codingbin.com/wp-content/uploads/2015/11/ajax-logo.jpghttp://codingbin.com/wp-content/uploads/2015/11/ajax-logo-150x150.jpgDev johnjQueryAjax is a very popular way to load the content without refresh the page . Ajax is a way to connect your application with the server in the back-end . Some times we need to use ajax in multiple places . So instead of creating ajax method on all...coding, php, wordpress, yii, cakephp, and  jquery

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request