Piyush Singh
Piyush Singh

Reputation: 611

$.get sending 2 requests instead of 1

I have a script function which makes a get request to the url

function openPage(url) {
     $.get(url+" #containerMain", function(data) {
    if (data.indexOf("<html id='loginPage'>") == -1) {
                $("#bodyMainTop").load(url); 
            } else {
                $("#containerMain").replaceWith(data);
            }
        }); 
 }

I use this method as

<a href="javascript: openPage('url')">Register Customer </a>

But instead of making 1 request this code is making 2 requests. It is also visible in the network tab of the browser.I am not able to figure this out. Can anyone provide me some guidance or can point me out the direction in which I can start debug.

Upvotes: 0

Views: 74

Answers (1)

madalinivascu
madalinivascu

Reputation: 32354

You have 2 ajax calls

1.$.get(url+" #containerMain",

2.$("#bodyMainTop").load(url);

so you get 2 xhr requests

Upvotes: 1

Related Questions