Hi,
i am at the end of a project and i have a very disturbing bug. i am reading a remote xml at this adress : https://seetch.com/api/user/tags
i am getting photos tags for a user with using wsse for security
here is my code (businessLogic) :
exports.getTagsForUser = function(success, error){ var wsse = require('BusinessLogic/getWSSE').getWSSE(); var wsseValue = 'UsernameToken Username="' + wsse.username + '", PasswordDigest="' + wsse.passwordDigest + '", Nonce="' + wsse.nonce + '", Created="' + wsse.created + '"'; var client = Ti.Network.createHTTPClient(); client.open('GET', 'https://seetch.com/api/user/tags', false); client.setRequestHeader('Authorization', 'WSSE profile="UsernameToken"'); client.setRequestHeader('x-wsse', wsseValue); var id, tag; var tags = []; client.onerror = function(e){ error(e.error); }; client.onload = function(e) { try{ var doc = this.responseXML; var elements = doc.getElementsByTagName('tag'); for(var i=0; i<elements.length; i++){ id = elements.item(i).getAttribute('id'); tag = elements.item(i).getElementsByTagName('name').item(0).text; tags.push({id: id, tag: tag}); } success(tags); } catch(Err){ error(Err); } }; client.send(); };First : strangely i have a lot of timeouts and when i connect to the website within a browser, it is quick and second, this code doesn't display tags on the iPhone and the activity indicator stays on the screen (not hided):
here is the code for the ui :
winSearch.addEventListener('open', function(e){ loadTags(); }); function loadTags(resetPullHeader) { indicateur.show(); rows = []; require('businessLogic/getTagsForUser').getTagsForUser( function update(tags){ for(var i=0; i<tags.length; i++) { var row = Ti.UI.createTableViewRow({ height: 30, backgroundImage : 'images/searchUnselected.png', selectedBackgroundImage : 'images/searchSelected.png', tag: tags[i].tag }); var tag = Ti.UI.createLabel({ text: tags[i].tag, color: 'white', left: 10 }); row.add(tag); rows.push(row); } searchTableView.setData(rows); indicateur.hide(); } }, function error(msg){ indicateur.hide(); alert(msg); } ); }on Iphone the activity indicator is never hided and it is very strange....
thanks for help...
1 Answer
Accepted Answer
When code runs in the simulator and doesn't run on the iphone, my first thought is that you have hit a case sensitivity problem. The simulator is not case sensitive when you reference filenames. But the phone is case sensitive.
So maybe you have a problem with one of your paths:
require('businessLogic/getTagsForUser')Maybe the actual filename is "GetTagsForUser.js", or it's in a folder called "BusinessLogic" ???
Also, just to be safe, I would use a "/" at the beginning of the path for all require() calls:
require('/businessLogic/getTagsForUser').HTH...
Your Answer
Think you can help? Login to answer this question!