Asynchronous and Synchronous request jQuery

Asynchronous and Synchronous request jQuery

When working is single page applications or on page operation without refreshing them on any event. Developer mostly use jQuery for smooth development. It will allow us Synchronous & Asynchronous request to fetch information from server or from any API.

Mostly developer used Asynchronous request but some time we have to load data first and then start processing on that data before provide end results. In Asynchronous we can't get this feature.

Like if we have A as Asynchronous and there are two more Asynchronous request inside the A then inner two Asynchronous request will execute parallel and may be one of them completed before other one. But in Synchronous if the first request is not completed the next one can't be start it's execution it is somehow dependency on other block of JavaScript.

Synchronous: A synchronous request blocks the client until it has completed the operation. In this case, the browser's javascript engine is blocked.

By default jQuery is not providing synchronous request, so we have to implicitly define synchronous request using $.ajax().

 $.ajax({
        type: "GET",
        url: web_url,
        async: false
    })

In the above code you can observe we are declaring false for the async parameter. Which will request in Synchronous.

Asynchronous: A request asynchronous does not block the client, i.e. The browser reacts. Users can also perform other operations at that time. In this case, the browser's javascript engine is not blocked.

Note: By default all ajax & jQuery request have "async:true".

要查看或添加评论,请登录

Junaid Shahid的更多文章

  • Most Reliable Real-time Communication Systems For your WEB Application

    Most Reliable Real-time Communication Systems For your WEB Application

    As Software engineers, we all have to face this at some time in our professional careers where we have to provide an…

  • Basis Of Programming Thought

    Basis Of Programming Thought

    Programming is more than just knowing the language of a computer. It's built on finely tuned logic to be a skilled…

  • Now Learn C# in easiest way !

    Now Learn C# in easiest way !

    C # is a great choice for a number of reasons if you are a new developer or someone who wants to learn a new language…

  • WHY LEARN C# & .NET Core?

    WHY LEARN C# & .NET Core?

    C # is one of the most versatile programming languages for desktop applications, background services, web applications…

  • Which is best, Laravel or CodeIgniter?

    Which is best, Laravel or CodeIgniter?

    There's going to be a clash between Laravel and CodeIgniter. CodeIgniter is old then the framework for Laravel.

    1 条评论
  • Custom Application or CMS

    Custom Application or CMS

    Most people prefer CMS, but I don't think it's the reliable approach to tackle real-time problems. Technology is…

社区洞察

其他会员也浏览了