Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AJAX called twice and success event runs second time.

$
0
0

Hi,

I am using ajax to rean an XML file as below.

function GetConfig(ConfigKey) {
    var returnvalue = 0;$.ajax({
        type: "GET",
        url: "PNRates.xml",
        datatype: "xml",
        success: function (xml) {
            var LatestConfig = $(xml).find('configs').find('Latest').text();
            //alert("success Values is :" + LatestConfig);
            returnvalue = parseInt(LatestConfig);
        },
        error: function (xhr, status, error) {
            //alert("Service Call Failed !" + error);
        }
    });
    //alert("returnvalue" + returnvalue);
    return returnvalue
}

When the GetConfig finction is called, only GET part is run for the first time and control goes back to the line where the function GetConfig  was called without going inside Success or error. Once all jquery is finished running, the control comes back directly to the success part. First time, the value returned from this function is 0 and second time it is whatever read from the XML file.

Can someone please help me understand why 0 is returned without executing success?


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>