Ajax plugin doesn't respond on iOS simulator

0 favourites
  • 2 posts
From the Asset Store
Body mass index (BMI) is a formula that uses weight and height to estimate body fat (both metric and imperial units incl
  • Link to .capx file (required!):

    dl.dropboxusercontent.com/u/186681453/bug_report/1/bug_report_20131111_r149.zip

    Steps to reproduce:

    1. Create a new project.

    2. Add Ajax plugin

    3. Add event: On "" completed

    4. Add action: Browser.Alert "complete"

    5. Add Button plugin

    6. Add event: On clicked

    7. Add action: AJAX.Request level001.json

    8. Export project-PhoneGap

    9. Test the project on iOS simulator

    10. Click Button

    Observed result:

    If click the button, no response. (no alert)

    Expected result:

    Alert "completed"

    Browsers affected:

    Chrome: no

    Firefox: no

    Internet Explorer: no

    It's working on browser.

    Operating system & service pack:

    Mac OS X 10.7.4

    iOS simulator Version 6.0 (369.2)

    phonegap 2.9.0

    Construct 2 version:

    R149

    cf)

    i modified

    C:\Program Files\Construct 2\exporters\html5\plugins\ajax\runtime.js

    as followings (two line, maked "//cranberrygame" beside it)

    and then works well on iOS simulator

    ...

              try

              {

                   request = new XMLHttpRequest();

                   request.onreadystatechange = function() {

                        // Note: node-webkit leaves status as 0 for local AJAX requests, presumably because

                        // they are local requests and don't have a HTTP response. So interpret 0 as success

                        // in this case.

                        //if (request.readyState === 4 && (isNodeWebkit || request.status !== 0))//cranberrygame

                        if (request.readyState === 4)//cranberrygame

                        {

                             self.curTag = tag_;

                             

                             if (request.status >= 400)

                                  self.runtime.trigger(cr.plugins_.AJAX.prototype.cnds.OnError, self);

                             else

                             {

                                  self.lastData = request.responseText.replace(/\r\n/g, "\n");          // fix windows style line endings

                                  

                                  // In node-webkit, don't trigger 'on success' with empty string if file not found

                                  //if (!isNodeWebkit || self.lastData.length)//cranberrygame

                                  if (self.lastData.length)//cranberrygame

                                       self.runtime.trigger(cr.plugins_.AJAX.prototype.cnds.OnComplete, self);

                             }

                        }

                   };

                   request.onerror = errorFunc;

                   request.ontimeout = errorFunc;

                   request.onabort = errorFunc;

                   request["onprogress"] = progressFunc;

                   

                   request.open(method_, url_);

                   

                   // Workaround for CocoonJS bug: property exists but is not settable

                   try {

                        request.responseType = "text";

                   } catch (e) {}

                   

                   if (method_ === "POST" && data_)

                   {

                        if (request["setRequestHeader"])

                        {

                             request["setRequestHeader"]("Content-Type", "application/x-www-form-urlencoded");

                        }

                             

                        request.send(data_);

                   }

                   else

                        request.send();

                   

              }

              catch (e)

              {

                   errorFunc();

              }

         };

    ...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I guess like node-webkit the iOS simulator sets a HTTP response code of 0 for completed requests. I made a change for the next build which hopefully fixes this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)