使用 httpClient (appcelerator) 进行多个请求

发布于 2024-09-08 23:44:14 字数 269 浏览 14 评论 0原文

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

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

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

这是我的代码 要点代码

With appcelerator, I am attempting to send a picture with the twitpic demo, I have created 2 text fields and when they are filled in I want to upload the image and those fields to twitpic.

The problem with the app, is after I do it successfully the first time, (without closing the app) the second time doesn't send.

I need to somehow reset the httpClient open so it will re-open it.

Here is my code gist code

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〃安静 2024-09-15 23:44:14

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

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();
}

You could add xhr.abort() to the end of you updateSuccess function to close the open connection first

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();
}
傲世九天 2024-09-15 23:44:14

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

I had the same problem, and resolved to creating a new HttpClient every time I make a request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文