小编典典

jQuery AJAX语法

ajax

我试图找到正确的语法以将变量传递给我的JQuery Post。

var id = empid;

$.ajax({
    type: "POST",
    url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
    data: "{empid: empid}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(result) {
        alert(result.d);
    }

我不认为数据:价值是正确的。有人让我挺直吗?

谢谢!


阅读 819

收藏
2020-07-26

共1个答案

小编典典

这个怎么样:

var id = empid;

$.ajax({
    type: "POST",
    url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
    data: "{empid: " + empid + "}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(result){
        alert(result.d);
        console.log(result);
    }
});
2020-07-26