Posted on

JasonP Implementaion on MVC Controller

public ActionResult UsageJasonP()
{
db.Configuration.LazyLoadingEnabled = false;
db.Configuration.ProxyCreationEnabled = false;
var waterusages = db.WaterUsages;

//return Json(waterusages, JsonRequestBehavior.AllowGet);
return new JsonpResult(waterusages,”receive”);
}

var url = “http://localhost:15214/water/UsageJasonP?callback=?”;

$.ajax({
url: url, dataType: “jsonp”, jsonpCallback: “receive”, callback: “receive”,
success: function (data, status) {
//mySurvey.closePopup();
alert(“Success”);
console.log(data);
},
error: function (xOptions, textStatus) {
alert(“fails”);
}
});

Leave a Reply

Your email address will not be published. Required fields are marked *