How to return Autocomplete response callback when all websql query finishedHTML5 WebSQL: how to know when a db transaction finishes?Javascript WebSQL query within for loop. How to know when finished?How to make a WebSQL query synchronous?javascript/WebSQL: how to cancel queryHow to return the result of a websql functionReturn a COUNT from a WebSQL query in a javaScript functionHow to “await” for a callback to return?SELECT Query in WebSQL in Safari is returning an errorHow to make query WebSQL not minus?Node JS Promise TypeError: Cannot read property 'then' of undefined

Redundant comparison & "if" before assignment

How to say when an application is taking the half of your screen on a computer

Why is this estimator biased?

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

Non-trope happy ending?

Why would a new[] expression ever invoke a destructor?

How to hide some fields of struct in C?

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

Keeping a ball lost forever

Can I say "fingers" when referring to toes?

Why "had" in "[something] we would have made had we used [something]"?

Why should universal income be universal?

Yosemite Fire Rings - What to Expect?

Terse Method to Swap Lowest for Highest?

Is aluminum electrical wire used on aircraft?

Why does a simple loop result in ASYNC_NETWORK_IO waits?

Does the UK parliament need to pass secondary legislation to accept the Article 50 extension

What should you do when eye contact makes your subordinate uncomfortable?

Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?

What should you do if you miss a job interview (deliberately)?

Why Shazam when there is already Superman?

Does Doodling or Improvising on the Piano Have Any Benefits?

Why can Carol Danvers change her suit colours in the first place?

How do apertures which seem too large to physically fit work?



How to return Autocomplete response callback when all websql query finished


HTML5 WebSQL: how to know when a db transaction finishes?Javascript WebSQL query within for loop. How to know when finished?How to make a WebSQL query synchronous?javascript/WebSQL: how to cancel queryHow to return the result of a websql functionReturn a COUNT from a WebSQL query in a javaScript functionHow to “await” for a callback to return?SELECT Query in WebSQL in Safari is returning an errorHow to make query WebSQL not minus?Node JS Promise TypeError: Cannot read property 'then' of undefined













0















I am trying to add offline capability to my web app. It has a autocomplete function and get it's source from ajax url. Ajax response is generated after several sql queries. This is working very fine.



Now i want to mak it offline. To do that i made my Database offline using Websql(though it deprecated) and managed to sync with server.



To make it offline i need to generate the source of autocomplete from the websql.
Here is my script sample



$("#add_item").autocomplete(
source: function (request, response)
if (!$('#poscustomer').val())
$('#add_item').val('').removeClass('ui-autocomplete-loading');
bootbox.alert('<?=lang('
select_above
');?>'
)
;
$('#add_item').focus();
return false;

var analyzed = analyze_term(request.term);
var term = analyzed.term,
option_id = analyzed.option_id,
warehouse_id = $("#poswarehouse").val(),
customer_id = $("#poscustomer").val(),
limit = 5;
var getProducts = new Promise(function (resolve, reject) );
Promise.all([getProducts]).then(function (values)
console.log(values);
response(values[0]);
);
,
minLength: 1,
autoFocus: false,
delay: 250,
response: function (event, ui)
console.log(ui);
if ($(this).val().length >= 16 && ui.content[0].id == 0)
bootbox.alert('No match found', function ()
$('#add_item').focus();

)
;
$(this).val('');

else if (ui.content.length == 1 && ui.content[0].id != 0)
ui.item = ui.content[0];
$(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', ui);
$(this).autocomplete('close');

else if (ui.content.length == 1 && ui.content[0].id == 0)
bootbox.alert('no_match_found', function ()
$('#add_item').focus();

)
;
$(this).val('');


,
select: function (event, ui)
event.preventDefault();
if (ui.item.id !== 0)
var row = add_invoice_item(ui.item);
if (row)
$(this).val('');
else
bootbox.alert('no_match_found ');


);


Above code example partially working. Here i have used another promise inside the map function. in that promise one property called 'options' added to the data object and this map function return an array of data object. When I log this data in console i get the 'option' property. By in the function response() i do not get this 'option property property



How can I solve this. I have tried many ways as my knowledge but always same result. then I found a npm package Web sql promisified but could not use as i need to run it on client side. I appreciate help.










share|improve this question




























    0















    I am trying to add offline capability to my web app. It has a autocomplete function and get it's source from ajax url. Ajax response is generated after several sql queries. This is working very fine.



    Now i want to mak it offline. To do that i made my Database offline using Websql(though it deprecated) and managed to sync with server.



    To make it offline i need to generate the source of autocomplete from the websql.
    Here is my script sample



    $("#add_item").autocomplete(
    source: function (request, response)
    if (!$('#poscustomer').val())
    $('#add_item').val('').removeClass('ui-autocomplete-loading');
    bootbox.alert('<?=lang('
    select_above
    ');?>'
    )
    ;
    $('#add_item').focus();
    return false;

    var analyzed = analyze_term(request.term);
    var term = analyzed.term,
    option_id = analyzed.option_id,
    warehouse_id = $("#poswarehouse").val(),
    customer_id = $("#poscustomer").val(),
    limit = 5;
    var getProducts = new Promise(function (resolve, reject) );
    Promise.all([getProducts]).then(function (values)
    console.log(values);
    response(values[0]);
    );
    ,
    minLength: 1,
    autoFocus: false,
    delay: 250,
    response: function (event, ui)
    console.log(ui);
    if ($(this).val().length >= 16 && ui.content[0].id == 0)
    bootbox.alert('No match found', function ()
    $('#add_item').focus();

    )
    ;
    $(this).val('');

    else if (ui.content.length == 1 && ui.content[0].id != 0)
    ui.item = ui.content[0];
    $(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', ui);
    $(this).autocomplete('close');

    else if (ui.content.length == 1 && ui.content[0].id == 0)
    bootbox.alert('no_match_found', function ()
    $('#add_item').focus();

    )
    ;
    $(this).val('');


    ,
    select: function (event, ui)
    event.preventDefault();
    if (ui.item.id !== 0)
    var row = add_invoice_item(ui.item);
    if (row)
    $(this).val('');
    else
    bootbox.alert('no_match_found ');


    );


    Above code example partially working. Here i have used another promise inside the map function. in that promise one property called 'options' added to the data object and this map function return an array of data object. When I log this data in console i get the 'option' property. By in the function response() i do not get this 'option property property



    How can I solve this. I have tried many ways as my knowledge but always same result. then I found a npm package Web sql promisified but could not use as i need to run it on client side. I appreciate help.










    share|improve this question


























      0












      0








      0








      I am trying to add offline capability to my web app. It has a autocomplete function and get it's source from ajax url. Ajax response is generated after several sql queries. This is working very fine.



      Now i want to mak it offline. To do that i made my Database offline using Websql(though it deprecated) and managed to sync with server.



      To make it offline i need to generate the source of autocomplete from the websql.
      Here is my script sample



      $("#add_item").autocomplete(
      source: function (request, response)
      if (!$('#poscustomer').val())
      $('#add_item').val('').removeClass('ui-autocomplete-loading');
      bootbox.alert('<?=lang('
      select_above
      ');?>'
      )
      ;
      $('#add_item').focus();
      return false;

      var analyzed = analyze_term(request.term);
      var term = analyzed.term,
      option_id = analyzed.option_id,
      warehouse_id = $("#poswarehouse").val(),
      customer_id = $("#poscustomer").val(),
      limit = 5;
      var getProducts = new Promise(function (resolve, reject) );
      Promise.all([getProducts]).then(function (values)
      console.log(values);
      response(values[0]);
      );
      ,
      minLength: 1,
      autoFocus: false,
      delay: 250,
      response: function (event, ui)
      console.log(ui);
      if ($(this).val().length >= 16 && ui.content[0].id == 0)
      bootbox.alert('No match found', function ()
      $('#add_item').focus();

      )
      ;
      $(this).val('');

      else if (ui.content.length == 1 && ui.content[0].id != 0)
      ui.item = ui.content[0];
      $(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', ui);
      $(this).autocomplete('close');

      else if (ui.content.length == 1 && ui.content[0].id == 0)
      bootbox.alert('no_match_found', function ()
      $('#add_item').focus();

      )
      ;
      $(this).val('');


      ,
      select: function (event, ui)
      event.preventDefault();
      if (ui.item.id !== 0)
      var row = add_invoice_item(ui.item);
      if (row)
      $(this).val('');
      else
      bootbox.alert('no_match_found ');


      );


      Above code example partially working. Here i have used another promise inside the map function. in that promise one property called 'options' added to the data object and this map function return an array of data object. When I log this data in console i get the 'option' property. By in the function response() i do not get this 'option property property



      How can I solve this. I have tried many ways as my knowledge but always same result. then I found a npm package Web sql promisified but could not use as i need to run it on client side. I appreciate help.










      share|improve this question
















      I am trying to add offline capability to my web app. It has a autocomplete function and get it's source from ajax url. Ajax response is generated after several sql queries. This is working very fine.



      Now i want to mak it offline. To do that i made my Database offline using Websql(though it deprecated) and managed to sync with server.



      To make it offline i need to generate the source of autocomplete from the websql.
      Here is my script sample



      $("#add_item").autocomplete(
      source: function (request, response)
      if (!$('#poscustomer').val())
      $('#add_item').val('').removeClass('ui-autocomplete-loading');
      bootbox.alert('<?=lang('
      select_above
      ');?>'
      )
      ;
      $('#add_item').focus();
      return false;

      var analyzed = analyze_term(request.term);
      var term = analyzed.term,
      option_id = analyzed.option_id,
      warehouse_id = $("#poswarehouse").val(),
      customer_id = $("#poscustomer").val(),
      limit = 5;
      var getProducts = new Promise(function (resolve, reject) );
      Promise.all([getProducts]).then(function (values)
      console.log(values);
      response(values[0]);
      );
      ,
      minLength: 1,
      autoFocus: false,
      delay: 250,
      response: function (event, ui)
      console.log(ui);
      if ($(this).val().length >= 16 && ui.content[0].id == 0)
      bootbox.alert('No match found', function ()
      $('#add_item').focus();

      )
      ;
      $(this).val('');

      else if (ui.content.length == 1 && ui.content[0].id != 0)
      ui.item = ui.content[0];
      $(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', ui);
      $(this).autocomplete('close');

      else if (ui.content.length == 1 && ui.content[0].id == 0)
      bootbox.alert('no_match_found', function ()
      $('#add_item').focus();

      )
      ;
      $(this).val('');


      ,
      select: function (event, ui)
      event.preventDefault();
      if (ui.item.id !== 0)
      var row = add_invoice_item(ui.item);
      if (row)
      $(this).val('');
      else
      bootbox.alert('no_match_found ');


      );


      Above code example partially working. Here i have used another promise inside the map function. in that promise one property called 'options' added to the data object and this map function return an array of data object. When I log this data in console i get the 'option' property. By in the function response() i do not get this 'option property property



      How can I solve this. I have tried many ways as my knowledge but always same result. then I found a npm package Web sql promisified but could not use as i need to run it on client side. I appreciate help.







      promise async-await web-sql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 6:31









      vahdet

      2,17631536




      2,17631536










      asked Mar 7 at 6:14









      DMGDMG

      11




      11






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037176%2fhow-to-return-autocomplete-response-callback-when-all-websql-query-finished%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037176%2fhow-to-return-autocomplete-response-callback-when-all-websql-query-finished%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

          Алба-Юлія

          Захаров Федір Захарович