Hi,
i am doing an application which make use of JQuery and Cakephp .
In this i am using like the following to retrieve the values from my controller side
var getformid;
$.getJSON("http://localhost/FormBuilder/index.php/forms/getFormEntry", function(json) {
getformid=json.forms[0]["id"];
alert("Form id inside "+getformid);
});//json
alert("Form id ouside "+getformid);
In the above code, the inner alert that is inside $.getJSON gives me the correct value as 75 But the outer alert showing me the error as getformid not defined..Why so??Can't we make use of the getformid available outside $.getJSON .Please suggest me.SInce i want to make use of that value for saving the Field ..
Edit: IF i try to use the code like
var getformid;
$.getJSON("http://localhost/FormBuilder/index.php/forms/getFormEntry", myCallback);
function myCallback (json) {
getformid = json.forms[0]["id"];
// You can work with the response here
}
i am getting the error like myCallback not defined.WHy so?? Also shall i use getformid value outside the function myCallback()