Using jQuery's getJSON method with an ASP.NET Web Form -


How do I call a method on an ASP.NET Web form page to use the getJSON method on jQuery?

The goal is:

  1. The user clicks the list list
  2. The value is sent to the server
  3. related to the server Luggage list, formatted using JSON
  4. Populate secondary box

I do not want to use an UpdatePanel, I used it several times using ASP Hundreds of work done. Net MVC framework, but it does not understand using the web form!

So far, I can do everything, including calling the server, does not call it correctly.

Thanks,
Some code:

  jQuery (document) .ready (function () {jQuery ("# ​​& lt;% = AreaListBox. Client ID% & gt; "). Click (function () {updateRegions (jQuery (this) .val ());});}); Function Update Regions (Region ID) {jQuery.getJSON ('/ Locations.aspx / GetRegions', {Area ID: Area ID}, Function (Data, Textstats) {Debugger;}); }   

Here's a simple example, which you should expect to get started: < / P>

  & lt;% @ Page language = "C #"%> & Lt;% @ import namespace = "System.Web.Services"% & gt; & Lt; Script runat = "server" & gt; [WebAmid] Public Static GetRegions (Int AIRID) {Return "FU" + Area ID; } & Lt; / Script & gt; & Lt ;! DOCTYPE html & gt; & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Head runat = "server" & gt; & Lt; Title & gt; JQuery and page methods & lt; / Title & gt; & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Script type = "text / javascript" & gt; $ (Function () {var areaId = 42; $ .ajax ({type: "POST", url: "Default.aspx / GetRegions", Data: "{areaId:" + AreaId + "}", Content Type: " Application / json; charset = utf-8 ", datatype:" jason ", success: work (data) {warning (data d);}});}); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -