...
// first call: success
REST.post(url, newScore, null, function (r)
{
// second call: success
this.getScoresCount(function (count_value)
{
var url = this._baseUrl + '/_metadata.json';
var newCount =
{
count: ++count_value
};
// third call: fails
REST.patch(url, newCount, function (r)
{
cc.log('test');
});
}.bind(this));
}.bind(this));
REST.patch():
REST.patch = function (url, json, callback)
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function ()
{
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400))
{
var response = xhr.response;
callback(response);
}
else
{
cc.log('readyState: ' + xhr.readyState);
cc.log('xhrStatus: ' + xhr.status);
cc.log('xhrStatusText: ') + xhr.statusText;
}
};
xhr.responseType = "json";
xhr.open("PATCH", url, true);
xhr.send(JSON.stringify(json));
};
Simulator console shows:
Simulator: readyState: 4
Simulator: xhrStatus: -1
Simulator: xhrStatusText:
What do i do to get it to work in device/simulator? (Web runs no problem)