Support Topics Documentation Slack YouTube Blog

JavaScript call hangs app


(Kam Rezvani) #1

Client is Appcelerator Titanium. I have created a sample project that recreates this problem.


(Vladimir Upirov) #2

Hello,
Yes, as far as I know Appcelerator Titanium has different env where JS is running and we have a patch for our JS-SDK which overrides some methods and gets it working, did you try this: https://github.com/Backendless/backendless-appcelerator ?
Regards, Vlad


(Mark Piller) #3

@vladimir-upirov, @kam-rezvani uses a raw REST request in his code, the patch for Appcelerator applies to our JS SDK uses in that platform so it is irrelevant here.


(Kam Rezvani) #4

I am trying both REST and JavaScript. I tried it with AppC patch and the app still hangs. Will send JS project link to support@backendless.com


(Vladimir Upirov) #5

I’ve run your app, but there was some mistakes in code

  1. when you use JS-SDK you do not need to encode url components, so you have to change this:

    — var whereClause = ‘ServletName%20%3D%20%27’ + environ + ‘%27’;
    +++ var whereClause = “ServletName=’” + environ + “’”;
    var queryBuilder = Backendless.DataQueryBuilder.create().setWhereClause(whereClause);

  2. as result of Backendless.Data.of(“TableName”).find(queryBuilder) you get Promise which will be resolve with already parsed data, so you don’t need to parse it manually

    ---- Backendless.Data.of(“TableName”).find(queryBuilder).then(function (e) {
    var parsedData = JSON.parse(e.text);

    +++ Backendless.Data.of(“TableName”).find(queryBuilder).then(function (parsedData) {

  3. in “catch” callback you will get JS Error object, so you should use

    .catch(function (error) {
    alert('ERROR: ’ + error.message + ’ CODE: ’ + error.code);
    })

this docs should help you https://backendless.com/docs/js/data_search_with_where_clause.html

Regards, Vlad


(Kam Rezvani) #6

Thank you for the fix Vladimir. Issue resolved.