Working code snippet for local!!! file ajax issue in wp8

0 favourites
  • 2 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • modification at C:\Program Files\Construct 2\exporters\html5\plugins\ajax\runtime.js

    makes local!!! file ajax in wp8 works well. (commented 6 //cranberrygame comments)

    this code snippet is for previous issue

    thanks

    ...

    try

    {

    //request = new XMLHttpRequest();//cranberrygame (1/6)

    request = new ActiveXObject("Microsoft.XMLHTTP");//cranberrygame (2/6)

    request.onreadystatechange = function()

    {

    if (request.readyState === 4)

    {

    self.curTag = tag_;

    if (request.responseText)

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

    else

    self.lastData = "";

    if (request.status >= 400)

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

    else

    {

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

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

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

    }

    }

    };

    //request.onerror = errorFunc;//cranberrygame (3/6)

    //request.ontimeout = errorFunc;//cranberrygame (4/6)

    //request.onabort = errorFunc;//cranberrygame (5/6)

    //request["onprogress"] = progressFunc;//cranberrygame (6/6)

    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
  • Alright, this works, but is non-standard. I've enabled that workaround code for Windows Phone 8 only and it seems to work. All other platforms will keep using the old standards-compliant code.

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