Reusable AJAX Functions (Post/Get)

Today, We want to share with you Reusable AJAX Functions (Post/Get).In this post we will show you Reusing AJAX function multiple times, hear for jquery multiple ajax calls in sequence we will give you demo and example for implement.In this post, we will learn about jQuery Ajax Calls in Web Applications with an example.

Reusable AJAX Functions (Post/Get)

There are the Following The simple About Reusable AJAX Functions (Post/Get) Full Information With Example and source code.

Read Also:  country state city Dynamic dependent dropdown using jquery in codeigniter

As I will cover this Post with live Working example to develop nested ajax calls, so the some problem with multiple ajax requests for this example is following below.

Reusable jQuery Ajax ($.ajax) Example

Reusable jquery ajax Function (index.html)


    
        
        <title>reusable jquery ajax - pakainfo.com</title>
    
    
	<h3>jQuery Ajax Calls in Web Applications</h3>

        
<!-- SCRIPTS -->

    
    function getMainUrl(url) {
        return '' + (url || '');
    }

    function doAjaxprocess(url, params, successCallback, errorCallback) {
        $.ajax({
            success : successCallback,
            error : errorCallback,
            data : params,
            url : url,
            type : 'POST',
            dataType : 'json'
        });
    }

    var user_type = "employee";
    doAjaxprocess(
        getMainUrl('do_submit_data_app.php?action=product_insert&user_type=' + user_type), 
        { 
            data : 'abc' 
        }, 
        function(resp) { 
            alert('Success');
            console.log(resp);
        },
        function(errorCallback) {
            alert('display some error');
            console.log(errorCallback);
        }
    );

    
    

Web Programming Tutorials Example with Demo

Read :

Read Also:  Update Query In Codeigniter Example Tutorial

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Reusable AJAX Functions (Post/Get).
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  jquery tabs refresh active tab on page reload
  2. Read Also:  How to Multiple urls in one Ajax call
  3. Read Also:  PHP Include and Require commands
  4. Read Also:  Wordpress set and get User last login Date and time
  5. Read Also:  Laravel Edit DropDown Option Seleted Example
  6. Read Also:  jQuery Check Uncheck All Checkbox Examples
  7. Read Also:  Reusable jquery AJAX requests Multiple Times
  8. Read Also:  get radio button value jquery
  9. Read Also:  Reuse Code in jquery Ajax Methods
  10. Read Also:  vuejs - How to implement Google New reCaptcha with checkbox
CLOSEX