Reuse Code in jquery Ajax Methods

Today, We want to share with you Reuse Code in jquery Ajax Methods.In this post we will show you jQuery Ajax Calls in Web Applications, hear for problem with multiple ajax requests we will give you demo and example for implement.In this post, we will learn about Intro to AJAX with jQuery Tutorial with an example.

Reuse Code in jquery Ajax Methods

There are the Following The simple About Reuse Code in jquery Ajax Methods Full Information With Example and source code.

As I will cover this Post with live Working example to develop jQuery’s Ajax-Related Methods, so the dependent ajax calls structures for this example is following below.

Also Read :  PHP Creating Dynamic Directory (Folder) Example

Reusing Code To Display Results

Example 1: reusable jquery ajax

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>reusable jquery ajax - pakainfo.com</title>

    </head>
    <body>
	<b>reusable jquery ajax - 1</b>
<?php 

define("GET_PROTOCOL", ((!empty($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] == 'https') || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ? "https://" : "http://");

$full_api_server_domain_path = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'icc.dream11.com';
//echo $full_api_server_domain_path;

define("MAIN_PATH", GET_PROTOCOL . $full_api_server_domain_path . '/dream11/admin/');
//echo MAIN_PATH;

?>
        
<!-- SCRIPTS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
    <script>
    function getMainUrl(url) {
        return '<?php echo MAIN_PATH; ?>' + (url || '');
    }

    function ajaxCallPostData(user_type, callbackSuccess, callbackError, callbackComplete) {
        $.ajax({
            type: 'POST',
            dataType: "json",
            url: getMainUrl('do_submit_ajax_data.php?action=product_insert&user_type=' + user_type),
            success: callbackSuccess,
            error: callbackError,
            complete: callbackComplete
        });
    }

    ajaxCallPostData('add_data_with_users', function (results) {
       console.log(results);
    }, function (results, error, back_complete) {
        console.log('Error Display Data');
        console.log(error);
        console.log(back_complete);
    });
    </script>
    </body>
</html>

Web Programming Tutorials Example with Demo

Read :

Also Read :  Laravel Delete Queued Jobs

Summary

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

I hope you get an idea about Reuse Code in jquery Ajax Methods.
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.