Alex Rivera | Logout

JQuery AJAX syntax

Asked 2009-04-23T02:02:21.240
12

I am trying to find the correct syntax to pass a varible to my 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);
    }

I don't think the data: value is quite right. Someone set me straight?

Thanks!

Edit
Report

1 Answer

0

if you want to send a JSON string to the server

data: "{empid: " + empid + "}"

if you want to send querystring params (?empid=123)

data: {empid : empid}
answered 2009-04-23T02:17:36.007

Your Answer