hi friends,
I'm trying to read an XML file using a jQuery 1.4 ajax ... the code is something like this ...

$.ajax({
    type: "GET",
    url: "abcde.xml",
    dataType: "xml",
    error: function(){
        /* error lines goes here */
    },
    success: function(){
        /* success lines goes here */
    }
});

it takes time to read the XML file (may be b'cause the file is huge) but it goes into the "error" code straight away and if made to wait the same code enters success codes. why so?
how to resolve this issue?

thanks :)

Recommended Answers

All 2 Replies

hi,
i've found the answer myself. i used

async:false

and it worked :)

BUT, now, i've another issue,
i've a jQuery plugin and i've written a global function (with the above lines of instruction) to read the XML file

function readFile(){
//....
$.ajax({
//...
/*code goes here*/
//...
});
//...
}

and i'm calling the function readFile() within the jQuery plugin. now, what seems to be happening is that the control goes to the readFile() function and it runs asynchronously and the control moves to the next line of code in the plugin, meanwhile executing the readFile() function in the background.

i want the readFile() function to be completely executed before the control moves to the next line of instruction within the plugin ...

how can i get the desired output?

any help is appreciated ...
thanks :)

I think $.get(); may do this. Please tell me if it works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.