且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery的将数据传递到AJAX功能

更新时间:2023-12-03 16:43:58

您已经无效的JSON:

You have invalid JSON:

"{ 'id', '2' }"

我会建议你调用它像这样,因为它会采取正确的编码参数的护理:

I would recommend you calling it like this as it will take care of properly encoding your parameters:

$.ajax({
    type: "POST",
    url: '../../../WebServices/ImageLibrary.svc/getimagesinfolder',
    dataType: 'json',
    data: JSON.stringify({ id: '2' }),
    contentType: "application/json; charset=utf-8",
    success: function (data) {
        alert('hello');
    }
});