JQuery AJAX syntax

前端 未结 9 1875
旧时难觅i
旧时难觅i 2021-01-17 20:11

I am trying to find the correct syntax to pass a varible to my JQuery Post.

var id = empid;

$.ajax({
    type: \"POST\",
    url: \"../Webservices/EmployeeS         


        
9条回答
  •  失恋的感觉
    2021-01-17 20:45

    It's not. You're passing a string, you should be passing an object literal,e.g.

    data: {"empid" : empid}
    

    See the difference? Assuming empid is a variable with some sort of value, that should work fine. Alternatively you can do this

    data: "empid="+empid
    

    http://docs.jquery.com/Ajax/jQuery.ajax#options

提交回复
热议问题