Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何构建AJAX请求_Jquery_Ajax_Wcf_Rest_Restful Url - Fatal编程技术网

Jquery 如何构建AJAX请求

Jquery 如何构建AJAX请求,jquery,ajax,wcf,rest,restful-url,Jquery,Ajax,Wcf,Rest,Restful Url,我需要从我的网页调用WCF服务。服务中的方法使用泛型列表作为参数,我需要知道如何构建ajax查询 方法: public List<FileListEntity> ListLogFiles(string status, List<FileListEntity> fileList) { .............//implementation.... return fileList; } 当jsonObj为null时,这第一次起作用,但当jsonObj包含值时

我需要从我的网页调用WCF服务。服务中的方法使用泛型列表作为参数,我需要知道如何构建ajax查询

方法:

  public List<FileListEntity> ListLogFiles(string status, List<FileListEntity> fileList)
{
  .............//implementation....
  return fileList;
}
当jsonObj为null时,这第一次起作用,但当jsonObj包含值时,第二次不起作用。 它说:

加载资源失败:服务器响应状态为500(内部服务器错误)

我认为第二次辩论没有正确通过。
有什么想法吗?如何解决。

终于找到了答案,我发送给服务的数据是错误的。 第一次改变

if (value == null) {
    jsonObj = "null";
}
else {
   jsonObj=value.d;
}
value.d(或value.data,在某些情况下,使用调试器检查)包含实际数据

第二次变更, 在ajax查询中写入:

data: JSON.stringify({ status: status, fileList: jsonObj })
而不是
data:'{“status”:“'+status+”,“fileList”:“+jsonObj+'}”,

data: JSON.stringify({ status: status, fileList: jsonObj })