jquery - How access data in JavaScript arrays using $.ajax -


this script when script executed want load data div of id #trial. script external array 3 names second trying call 'sarah'. whats wrong?

<script> $(document).ready(function(){     $("#trial").click(function(){         var attempt=$.ajax({             url: "names.js",             datatype: "script"         });         var msg=names[1];         attempt.done(function( msg ) {             $( "#trial" ).html( msg );         });     }); }); </script> 

change code this:

<script>    $(document).ready(function(){        $("#trial").click(function(){             $.ajax({                  url: "names.js",                  datatype: "script",                  success: function(res){                       //todo res                  }            });        });    }); </script> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -