Singh Piyush Singh Piyush - 1 year ago 130
Ajax Question

$.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.

Answer Source

You have 2 ajax calls

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

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

so you get 2 xhr requests

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download