Skip to content

Commit

Permalink
fUpdateDeviceToServer should go though the bridge due to cross domain…
Browse files Browse the repository at this point in the history
… issue
  • Loading branch information
torinnguyen committed Dec 3, 2011
1 parent 7ae9ceb commit 396cc53
Showing 1 changed file with 6 additions and 37 deletions.
43 changes: 6 additions & 37 deletions js/JSCore/cProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,45 +179,14 @@ cProxy.fUpdateDeviceToServer = function(
)
{
var vUrl = "http://netv.bunnie-bar.com/torin/webservices/update_device.php";
var self = this;

if (!window.XMLHttpRequest) // Mozilla/Safari
{
if (vCompleteFunc)
vCompleteFunc("XMLHttpRequest doesn't exist.");
return;
}

var xmlHttpReq = new XMLHttpRequest();
xmlHttpReq.open("post", vUrl, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function()
{
if (xmlHttpReq.readyState == 4)
{
switch (xmlHttpReq.status)
{
case 200:
if (vCompleteFunc)
vCompleteFunc(xmlHttpReq.responseText);
break;
case 0:
if (vCompleteFunc)
vCompleteFunc(0);
break;
}
}
}
vPostParam = vPostParam ? vPostParam : "";

// POST data
var parameters = "";
for (var o in vPostParam)
parameters += o + "=" + encodeURIComponent(vPostParam[o]) + "&";
if (parameters.substr(parameters.length - 1, 1) == "&")
parameters = parameters.substr(0, parameters.length - 1);

// Send it
xmlHttpReq.send(parameters);
cProxy.xmlhttpPost("./bridge", "post", {cmd : "GetURL", url : vUrl, post : vPostParam}, function(vData) {
//~ fDbg(vData);
if (vCompleteFunc)
vCompleteFunc(vData);
});
}


Expand Down

0 comments on commit 396cc53

Please sign in to comment.