weixin_33698043 2015-06-01 06:24 采纳率: 0%
浏览 45


I need to call a WCF service from my webpage. The method in service uses generic list as an argument,i need to know how to frame the ajax query?


  public List<FileListEntity> ListLogFiles(string status, List<FileListEntity> fileList)
  return fileList;

1st time when method is called the 'fileList' is passed as null, this method populates the list and the send it back to the website. 2nd time the website sends the received fileList along with some status back to the service.

ajax query:

var status = defineStatus();
var value;
var jsonObj;
function callLogService(){

    if (value == null) {
        jsonObj = "null";
    else {
        type: "POST",
        url: "http://localhost:56256/SearchService.svc/ListLogFiles",
        data: '{"status":"'+ status+'","fileList":'+jsonObj+' }',
        crossDomain: true,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        processdata: true,
        success: function (response) {
            value = response;
        error: function () {
            alert("An error has Occured, Please try refreshing !");


This works 1st time when jsonObj is null but doesn't works the second time when jsonObj contains value. It says:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

I think that the argument is not passed correctly during second time. Any idea? how to resolve.

  • 写回答

1条回答 默认 最新

  • weixin_33721427 2015-06-01 11:26

    finally found the answer, the data i'm sending to the service is wrong. 1st change

    if (value == null) {
        jsonObj = "null";
    else {

    value.d(or value.data in some case, check using debugger) contains the actual data.

    2nd change, Inside the ajax query write:

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

    instead of data: '{"status":"'+ status+'","fileList":'+jsonObj+' }',




  • ¥15 App的会员连续扣费
  • ¥15 不同数据类型的特征融合应该怎么做
  • ¥15 用proteus软件设计一个基于8086微处理器的简易温度计
  • ¥15 用联想小新14Pro
  • ¥15 multisim中关于74ls192n和DSWPK开关仿真图分析(减法计数器)
  • ¥15 基于8255的交通灯设计
  • ¥15 w3wp,exe 中发生未处理的 Microsoft ,NETFramework 异常。
  • ¥20 C51单片机程序及仿真(加减器)
  • ¥15 AQWA | 水动力分析 二阶波浪力
  • ¥15 c语言题目:成绩管理系统