Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to recieve JSON from Webmethod using $.getJSON or Ajax call
    primarykey
    data
    text
    <p>I have some JSON objects that I want to process on Client Side, but My WebMethod that I specified does not want to fire.</p> <p>Here is the Ajax and GetJson methods i used in my Client Side Script: GetSJON</p> <pre><code>$(document).ready(function() { $(document).ready(function() { //attach a jQuery live event to the button $('#getdata').live('click', function() { $.getJSON('/Members_Only/StockMovement/WebForm1.aspx/StockPlacementOptions', function(data) { //alert(data); //uncomment this for debug // alert(data.item1 + " " + data.item2 + " " + data.item3); //further debug $('#showdata').html("&lt;p&gt;item1=" + data.item1 + " item2=" + data.item2 + " item3=" + data.item3 + "&lt;/p&gt;"); }); }); }); </code></pre> <p>Here is the Ajax</p> <pre><code>$(document).ready(function () { $.ajax({ type: "POST", url: "/Members_Only/StockMovement/WebForm1.aspx/StockPlacementOptions", contentType: "application/json; charset=utf-8", dataType: "json", data: "{}", success: function (res) { $('#Results').append(CreateTableView(res)).fadeIn(); } }); }); </code></pre> <p>Both of these Methods Call StockPlacementOptions which is my WebMethod that look like this:</p> <pre><code> [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)] public static List&lt;StockReturnMethod&gt; StockPlacementOptions() { scmEntitiesPrimaryCon entities = new scmEntitiesPrimaryCon(); var binOptions = (from avail in entities.ProductAvailibleBins(1, 2) select new StockReturnMethod() { LotID = (int)avail.LotID, LotName = avail.LotName, AreaID = (int)avail.AreaID, AreaName = avail.AreaName, BinID = (int)avail.BinID, BinName = avail.BinName }).ToList(); return binOptions; } </code></pre> <p>If I can just get the JSON web Method to fire on $(document).ready event, I will be able to process and work with the data from there. I have also tried looking at a diffrent jQuery library like <a href="http://knockoutjs.com/documentation/json-data.html" rel="nofollow">KnockoutJS</a> with it's data processing capability, also no luck. I am using ASP Webforms on Framework 4 with Html5 Markup.</p> <p>Any advice will be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload