Calling and writing javascript functions
Posted
by Ankur
on Stack Overflow
See other posts from Stack Overflow
or by Ankur
Published on 2010-04-19T06:20:30Z
Indexed on
2010/04/19
6:23 UTC
Read the original article
Hit count: 181
I think I have not got the syntax correct for writing a javascript function and calling it to assign its return value to a variable.
My function is:
getObjName(objId){
var objName ="";
$.ajax( {
type : "GET",
url : "Object",
dataType: 'json',
data : "objId="+objId,
success : function(data) {
objName = data;
}
});
return objName;
}
I am trying to call it and assign it to a variable with:
var objName = getObjName(objId);
However Eclipse is telling me that "there is no such function getObjName() defined"
© Stack Overflow or respective owner