Titanium httpclient第二次失败

时间:2015-10-08 08:18:08

标签: titanium httpclient

已经坚持好几天了。我已经谷歌了,但对此没有任何建议。所以任何帮助都会受到很多赞赏。我最近将JSON数据发布到Web服务Titanium。例如:我提供了注册和取消注册模块的服务。首先,当我注册这个模块时:

var xhr = Ti.Network.createHTTPClient({
    enableKeepAlive: false
});
xhr.timeout=2000;
xhr.onerror=function(){};

xhr.onload = function(e){
//Ti.API.info(this.responseText);
var response= JSON.parse(this.responseText);
//Ti.API.info(response.err+'  '+response.msg);
if (response.err==0){
        alert(response.msg);
        win.close();
  };         
var link='https://dttc.haui.edu.vn/RegisterSubject';       

xhr.open('POST',link);
var params=({            
  s:Ti.App.Properties.getString('Student_ID',''),
  t:win.trainingid
});
xhr.send(params); 

完美无缺。然后我使用相同的代码取消注册,但在不同的窗口中使用不同的链接,它会冻结我的应用程序,即使它取消注册:

    var xhr = Ti.Network.createHTTPClient({
    enableKeepAlive: false
});
xhr.timeout=2000;
xhr.onerror=function(){};

xhr.onload = function(e){
//Ti.API.info(this.responseText);
var response= JSON.parse(this.responseText);
//Ti.API.info(response.err+'  '+response.msg);
if (response.err==0){
        alert(response.msg);
        win.close();
  };         
var link='https://dttc.haui.edu.vn/UnRegisterSubject';       

xhr.open('POST',link);
var params=({            
  s:Ti.App.Properties.getString('Student_ID',''),
  t:win.trainingid
});
xhr.send(params);

如果您有任何建议,请留下任何评论?

0 个答案:

没有答案