c# - Jquery AJAX sending JSON to web API 2 function -
hey not sure why not able send data in json format web api 2 function.
my ajax:
$('#btsubmit0').click(function () { $.ajax({ url: "/febclassifieds/", type: "get", crossdomain: true, contenttype: 'application/json; charset=utf-8', datatype: "jsonp", data: json.stringify({ febid: "3a7c1773-128a-4b11-81f8-76302a678ddd" }), success: function (data) { console.log(data); }, error: function (xmlhttprequest, textstatus, errorthrown) { console.log('error: ', xmlhttprequest); } }); }); my web api function code:
[httpget] [route("febclassifieds/{febid}")] public ihttpactionresult getfebclassifieds(febclassifieds.febclassifiedsvars data) { try { ....code here......(never gets part anyways) } } the functions class:
namespace webapi.app.classes { public class febclassifieds { public class febclassifiedsvars { public string febid { get; set; } } } } it never fires function off when testing out local. tells me error of:
get http://localhost:55473/febclassifieds?callback=jquery17105937835655640811_1454958628992&{%22febid%22:%223a7c1773-128a-4b11-81f8-76302a678ddd%22}&_=1454958676643
in console...
what possibly missing in order working?
change type:"get" type:"post" if want send json format.
Comments
Post a Comment