前台,aspx页面
<script type="text/javascript">
$(function () {
$(".span-active").click(function () {
var id = 1;
$.ajax({
url: "ProDetails.ashx",
type: "post",
data: { id: id, likeProder: "nolike" },//传递多个值
//data:"id="+id,//传递单个值
dataType: "json",
success: function (data) {
},
error: function () {
}
});
});
});
</script>
后台,我使用的是在ashx
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
int id = Convert.ToInt32(context.Request.Form["id"]);//转换类型
string namelike = context.Request.Form["likeProder"];
}