Permalink
Browse files

fUpdateDeviceToServer should go though the bridge due to cross domain…

… issue
  • Loading branch information...
1 parent 7ae9ceb commit 396cc5322acd72c8e41061b4efff73b713ded20d @torinnguyen torinnguyen committed Dec 3, 2011
Showing with 6 additions and 37 deletions.
  1. +6 −37 js/JSCore/cProxy.js
View
@@ -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);
+ });
}

0 comments on commit 396cc53

Please sign in to comment.