简体   繁体   中英

JQuery Ajax only work with synchronous Ajax call and no response for asynchronous Ajax call

I updated my app's phonegap from 0.9.3 to 2.2.0 and also jQuery from 1.4.4 to 1.6.4. I tested the apps on a few device.

  • For Android 2.3 - the apps is working fine(able to do a ajax call with username and password).
  • For Android 3.2 - Ajax call keep loading and wait response from server.
  • For Android 4.0 - Ajax call keep loading and wait response from server.
  • For Android 4.1.2 - Ajax call keep loading and wait response from server.

The app are currently using asynchronous call and not able to receive response from server. I tested the app using synchronous call and everything is working fine(able to send and receive response form server). The reason why I wanted to use asynchronous call is that I don't want to lock up the screen.

Anyone have any idea regarding this problem ?

Below is my code.

$.ajax({
                type: "GET",
                username: uname,
                password: pword,
                cache: false,
                data: null,
                url: baseURL+'weeks',
                dataType: "xml",
                contentType: "application/xml;charset=utf-8",
                crossDomain: false,
                error: loginErrorHandler,
                success: weeksParse,

            });

Try removing the "," from the success function:

        $.ajax({
            type: "GET",
            username: uname,
            password: pword,
            cache: false,
            data: null,
            url: baseURL+'weeks',
            dataType: "xml",
            contentType: "application/xml;charset=utf-8",
            crossDomain: false,
            error: loginErrorHandler,
            success: weeksParse  // <----------- remove the last comma ','

        });

and see if this works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM