我想使用 jQuery.get()
向 asp.net 页面发出请求。
Url 格式应该如何,以及如何获取随数据发送的参数?
我尝试过这样的:
$.ajax({
type: "POST",
url: "sendEmail.php",
data: "{name:'" + name + "', message:'" + msg + "', mailTo :'" + to + "' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
$('#email_form').html("<div id='message'></div>");
$('#message').append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function () {
$('#message').append("<img id='checkmark' src='images/check.png' />");
});
});
});
但我想在 asp.net 中调用电话。
最佳答案
jQuery.get() - Load data from the server using a HTTP GET request
documentation - http://api.jquery.com/jQuery.get/
$.get(
// your aspx page
"yourpage.aspx",
// object literal used to populate query string
{ param1: "foo", param2: "bar" },
// capture response in callback
function(data){
alert("Results: " + data);
}
);
要从Code-Behind
访问参数,请使用:
HttpContext.Current.Request.QueryString["param1"].ToString();
或更简洁地说:
Request.QueryString["param1"].ToString();
关于jquery - 我如何获取 jQuery.Get(); 上的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9152191/