Ajax plugin doesn't respond on iOS simulator

Bugs will be moved here once resolved.

Post » Mon Nov 11, 2013 2:01 pm


Link to .capx file (required!):
https://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();
          }
     };
...
Construct2 Cordova Plugins (currently 87 plugins): https://www.scirra.com/store/construct2 ... ugins-1662

Construct2 Prototype Capx (currently 50 capx): https://www.scirra.com/store/games-with ... -capx-3088

Home page: http://cranberrygame.com
B
65
S
22
G
81
Posts: 780
Reputation: 46,631

Post » Mon Nov 11, 2013 7:58 pm

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.
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests