【发布时间】:2016-04-18 08:54:54
【问题描述】:
如果有人可以使用 Jquery 解释 Ajax 调用并将其传递给控制器方法,那就太好了。 用一个解释 句法 示例
// Using the core $.ajax() method
$.ajax({
// The URL for the request
url: "post.php",
// The data to send (will be converted to a query string)
data: {
id: 123
},
// Whether this is a POST or GET request
type: "GET",
// The type of data we expect back
dataType : "json",
})
// Code to run if the request succeeds (is done);
// The response is passed to the function
.done(function( json ) {
$( "<h1>" ).text( json.title ).appendTo( "body" );
$( "<div class=\"content\">").html( json.html ).appendTo( "body" );
})
// Code to run if the request fails; the raw request and
// status codes are passed to the function
.fail(function( xhr, status, errorThrown ) {
alert( "Sorry, there was a problem!" );
console.log( "Error: " + errorThrown );
console.log( "Status: " + status );
console.dir( xhr );
})
// Code to run regardless of success or failure;
.always(function( xhr, status ) {
alert( "The request is complete!" );
});
如果有人可以使用 Jquery 解释 Ajax 调用并将其传递给控制器方法,那就太好了。 用一个解释 句法 示例
【问题讨论】:
-
到底什么不清楚?
-
我想知道如何使用 Ajax JQuery 在 asp.net mvc 中调用控制器中的操作方法。 @弗拉基米尔
-
“语法示例” - w3schools.com/php/php_ajax_php.asp 用于 ajax 语法。环顾四周
-
查看我的编辑。我想知道 ajax 中的函数,如 url、数据类型等。@VelimirTchatchevsky
-
@raghav 你有没有尝试用谷歌搜索任何例子?来自简单谷歌搜索“aso.net mvc ajax jquery”的第一个链接将返回您需要的一切 - mikesdotnetting.com/article/220/…
标签: jquery ajax asp.net-mvc asp.net-ajax