On my Page I've got DropDownList, Date Picker and ASP.NET Button.
When I pick up date and something from list, after click, it should show Google Map with few markers. I'm using Web Method to find records in data base filtered by items from list and datepicker.
When I'm trying to get these records from WebMethod I used AJAX which returns good JSON, but I've got error: Too much recursion
.
I tried this JS code:
function myFun() {
DrawMap();
var SelectedItem = document.getElementById("ctl00_PageContent_DropDownList").value;
var SelectedDate = document.getElementById("ctl00_PageContent_DatePicker").value;
PageMethods.MyWebMethod(CarReg, SelectedDate, function (result) {
parsed = JSON.parse(result);
});
Where function(result){ parsed = JSON.parse(result);
assigns result to global variable parsed
.
In my button I've got attribute OnClientClick
with value myFun(); return false;
because after postback my map doesn't work. It works, but I have to click twice.
I noticed that when I do alert(parsed);
after call MyWebMethod
I got undefined.
Why parsed
is undefined after assign result?