我可以使用javascript / jquery绑定asp.net下拉列表吗?我从web方法获取jquery ajax中的数据,所以我想避免回发。但是我仍然希望使用服务器端代码进行回发并保存所有数据(即我仍然可以使用客户端脚本绑定它之后能够执行此操作{.1}}。
是否有可能并且有人能解释我如何做到这一点?
谢谢,
答案 0 :(得分:0)
使用Json ajax
语法:
$.ajax({
dataType: "json",
url: url,
data: data,
success: success
});
请参阅json的简单示例:
<script type="text/javascript">
$(document).ready(function () {
var msgbox = $("#status");
$("#Button1").click(function () {
$.ajax({
type: "POST",
//Page Name (in which the method should be called) and method name
url: "BeginJson.aspx/CheckDateTime",
// If you want to pass parameter or data to server side function you can try line
// data: "{}",
//else If you don't want to pass any value to server side function leave the data to blank line below
data: "{'args':'Somnath'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
//Got the response from server and render to the client
msgbox.html(msg.d);
}
});
});
});