【问题标题】:Multiple Requests with httpClient (appcelerator)使用 httpClient (appcelerator) 的多个请求
【发布时间】:2011-03-13 20:56:50
【问题描述】:

使用 appcelerator,我正在尝试发送带有 twitpic 演示的图片,我创建了 2 个文本字段,当它们填写完毕后,我想将图像和这些字段上传到 twitpic。

应用程序的问题是,在我第一次成功完成后,(没有关闭应用程序)第二次没有发送。

我需要以某种方式重置 httpClient 打开,以便它重新打开它。

这是我的代码gist code

【问题讨论】:

    标签: iphone post httpclient appcelerator httpconnection


    【解决方案1】:

    您可以在 updateSuccess 函数的末尾添加 xhr.abort() 以首先关闭打开的连接

    function networkUpdateSuccess() {
      alert('Success Uploaded',Ti.App.globalImage);
      win.rightNavButton = null;
      Ti.App.globalImage = null;
      whatText.value = '';
      whereText.value = '';
      actInd.hide();
      upload.hide();
      previewImage.image = '../images/upload_image.png';
      xhr.abort();
    }
    

    【讨论】:

    • 虽然你可能想先检查常量(DONE、LOADING、OPENED、UNSENT),看看它是否准备好了
    【解决方案2】:

    我遇到了同样的问题,并决定每次发出请求时都创建一个新的 HttpClient。

    【讨论】:

      猜你喜欢
      • 2018-10-02
      • 2019-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-30
      • 1970-01-01
      相关资源
      最近更新 更多