Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4500] iOs: onload after upload image - Ti.Network.createHTTPClient

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNeeds more info
Resolution Date2016-09-24T16:45:19.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterAndrea Salini
AssigneeShak Hossain
Created2016-09-23T08:54:52.000+0000
Updated2016-09-26T11:41:25.000+0000

Description

Create an HTTP request, with a properly server method to accept the request, and upload an image in method send. When try to call onload method of HTTP request, it works for Android, but not for iOS. So, if you need to do some action after server response, it's impossibile to do it on iOs.

Comments

  1. Sharif AbuDarda 2016-09-23

    Hello, We need a sample test code and your test environment where the issue is regeneratable. Send us these. We will look into it. Thanks.
  2. Hans Knöchel 2016-09-23

    Make sure you call onload on creation, so as part of Ti.Network.createHTTPClient(). I'm pretty sure it works, since there are production apps out there that use this very common feature.
  3. Hans Knöchel 2016-09-24

    We need more info in order to test and prioritize this properly. Please attach at least: - Full environment (Titanium SDK-version, iOS version) - Full trace-log - Example-code (that fit's into a single-executive app.js file)
  4. Andrea Salini 2016-09-26

    //The first xhr call is about a backend method that create an object related with the files i need to save var xhr = Ti.Network.createHTTPClient({ onload: function() { activityIndicator.hide(); var risposta = JSON.parse(this.responseText); //variable foto is my array of images if (foto.length>0){ for(var i = 0; i < foto.length; i++){ var xhr1 = Ti.Network.createHTTPClient({onload: function() { alert('check enter onload'); if(i==(foto.length-1)){ activityIndicator.hide(); Ti.include('/attivit/lista.js'); win1 = lista(activityIndicator); win_pranzo.add(win1);} alert('check stop'); }}); //url is the backend method to upload the foto. It has some information about the object created in xhr method, so it's similar to 'https://theurl.com/method?object=risposta' where risposta is var risposta = JSON.parse(this.responseText); (see up) received from xhr xhr1.open('POST',url); xhr1.send({multifile: foto[i]}); } } else { Ti.include('/attivit/lista.js'); win1 = lista(activityIndicator); win_pranzo.add(win1); } } }); In this way android enters in onload method and xhr and xhr1 without problems, so i can see both alert. For iOs it's not possible, and also the first alert with 'check enter onload' is not displayed. Log don't display anything about this problem, so it's not useful to attach. SDK version: 5.1.2, 5.4.0, 5.5.0 (i have the same problem in all those versions) iOs version: 9 and 10 (i have the same problem in all those versions)

JSON Source