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
Post a Comment