JQuery Sometimes loads, sometimes not -


my main problem:

1/ load page have autocomplete (a) - click load only, not ctrol f5 or f5

2/ autocomplete works, not

the error below: http://i.stack.imgur.com/2leot.png [this capture image "luckly" take firebug]

real testing on video youtube: https://youtu.be/2osbelhapjk

how fix them, have stacken 3 days... please ! have seen thread this, no true answer...

$("#txtsavedtg").autocomplete({          source: function (request, response) {              var param2 = { name: $('#txtsavedtg').val() };              $.ajax({                  url: "../../usercontrols/loaddataservice.asmx/autogui",                  data: json.stringify(param2),                  datatype: "json",                  type: "post",                  contenttype: "application/json; charset=utf-8",                  datafilter: function (data) { return data; },                  success: function (data) {                        if (data.d.length == 0) {                            $('#txtsavedtg').attr("placeholder", "value not found '" + $('#txtsavedtg').val() + "'");                          $('#txtsavedtg').val("");                      } else {                          response($.map(data.d, function (item) {                              return {                                  value: item["name"]                              }                          }))                      }                  },                  error: function (xmlhttprequest, textstatus, errorthrown) {                      alert(textstatus);                  }              });          },          minlength: 1      });

that error means jquery or plugin hasn't yet been loaded. sounds there in race, check you're function call isn't getting hit before document loaded:

    $(function(){         $("#txtsavedtg").autocomplete({         source: function (request, response) {             var param2 = { name: $('#txtsavedtg').val() };             $.ajax({                 url: "../../usercontrols/loaddataservice.asmx/autogui",                 data: json.stringify(param2),                 datatype: "json",                 type: "post",                 contenttype: "application/json; charset=utf-8",                 datafilter: function (data) { return data; },                 success: function (data) {                      if (data.d.length == 0) {                          $('#txtsavedtg').attr("placeholder", "value not found '" + $('#txtsavedtg').val() + "'");                         $('#txtsavedtg').val("");                     } else {                         response($.map(data.d, function (item) {                             return {                                 value: item["name"]                             }                         }))                     }                 },                 error: function (xmlhttprequest, textstatus, errorthrown) {                     alert(textstatus);                 }             });         },         minlength: 1     }); }); 

also check path javascript files correct.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -