I use this method as a wrapper so that I can send parameters. Also, the use of variables at the top of the method allows you to minimize it with a higher coefficient and allows you to reuse the code when making several similar calls.
function InfoByDate(sDate, eDate){ var divToBeWorkedOn = "#AjaxPlaceHolder"; var webMethod = "http://MyWebService/Web.asmx/GetInfoByDates"; var parameters = "{'sDate':'" + sDate + "','eDate':'" + eDate + "'}"; $.ajax({ type: "POST", url: webMethod, data: parameters, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $(divToBeWorkedOn).html(msg.d); }, error: function(e){ $(divToBeWorkedOn).html("Unavailable"); } }); }
I hope this helps.
Note that this requires the 3.5 framework to display JSON web methods that can be used in this way.
Bobby Borszich Jan 27 '09 at 22:08 2009-01-27 22:08
source share