In modern web-projects that use RESTful API\'s we often see AJAX-calls like the one below littered around our JavaScript-files.
$.ajax({
type: \"POST\",
This excellent another project allows you to do what you asked for.
This poject auto-generates JavaScript proxies for MVC and WebApi controllers.
And, this project covers WebApi features such as custom ActionName attributes.
With this project, you will have also the Intellisense.
http://jsnet.codeplex.com/
Example of Intellisense
window.test = function test() {
///
///This example works.
///You have the Intellisense. It's great!!!
///No hard coded url.
///
//-- settings of ajax request.
var a = $dpUrlSet.Customer.Create.$action0.$AjaxSettings();
//-- your parameters of action method
a.data.name = "Scott Gu";
a.data.address = "Somewhere in Redmond";
//-- stringify
a.data = JSON.stringify(a.data);
//-- send ajax request
var xhr = $.ajax(a);
xhr.success(function (id) {
/// Response of ajax request
//-- settings of ajax request.
var a = $dpUrlSet.Customer.Update.$action0.$AjaxSettings();
//-- your parameters of action method
a.data.id = id;
a.data.name = "Scott Gu";
a.data.address = "Somewhere in Seattle";
//-- stringify
a.data = JSON.stringify(a.data);
//-- send ajax request
var xhr = $.ajax(a);
});
}