jquery - onclick JavaScript function gives error: the function is not defined -


i getting error when calling onclick function. when comment ajax call, works fine. if ajax call there, function not work, give error:

searchuser not defined

function searchuser() {     try {         var userid = document.getelementbyid("uuid");         alert(userid);          .ajax({             type: "get",             url: "/ajax/searchuser.cfm"             data: {                 method: "searchuser",                 empid: userid             },             success: function(data) {                 if (data != "") {                                     } else {                     var tempstr = data.substring(1, data.length - 1);                     var resultarray = tempstr.split(",");                     var firstname = resultarray[0];                     var lastname = resultarray[1];                     var firstnameelem = document.getelementbyid("firstname");                     var lastnameelem = document.getelementbyid("lastname");                     firstnameelem.value = firstname;                     lastnameelem.value = lastname;                 }             }         });     } catch (err) {         alert(err);     } } 
<div class="row uniform">     <div class="12u">         <button type="button" class="button" onclick="searchuser()" value="search"> </button>     </div> </div> 

your browser stops compile (or better interprete) code if there error , means function cant used. means error inside .ajax. in comments under questions find misstakes.

the "try...catch" doesnt catches syntax error, runtime errors stackoverflow (:d)


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -