Hi friends, I have small doubt in ajax function in asp.net
I have one ajax function which is called on Page Load of Site1.Master so that I can use that result out come from the function in all pages that inherit from site1.master.
So I have placed that ajax function in separate js file and included that file in my site1.master at first place before other js files to inculde.
When that site1.master loads (most probably after the user login) I am able to go to the function, but I am unable to go to either "Success" or "error" functions. so I have added a attribute "async:false". still the problem is persists.
Please any one can help me.
Here is my ajax code in ap.js file
var AllItems = new Array();
function GetAllItemsOnLoad() {
var aid = 1;
var param = '{"AgencyId":"' + aid + '"}';
try {
$.ajax
({
type: "POST",
async: false,
contentType: "application/json; charset=utf-8",
url: WebSvcUrl + "/GetAllItems",
data: param,
dataType: "json",
success: OnSuccessGetAllItemsOnLoad,
error: OnFailOfGetAllItemsOnLoad
});
}
catch (err)
{ alert("Unable to get the data, Please Try again"); }
}
function OnSuccessGetAllItemsOnLoad(msg) {
try
{
if (msg.d != null)
{
AllItems = msg.d;
}
else
{
alert("Unable to retrive data, Please Try again");
}
}
catch (err)
{ alert("Unable to get the data, Please Try again"); }
}
function OnFailOfGetAllItemsOnLoad(request, status, error) {
$("#lblErrIname").html("Unable to get the data, Please Try again");}
Here is the code I am calling in my site1.Master page
if (LoginUser == 3)
{
ShowAdminDiv();
GetAllItemsOnLoad();
}
Please any one Could tell me where I am wrong.
Thanks and Regards
Ganesh