jQuery - Ajax不会返回JSON数据

时间:2014-06-03 22:18:06

标签: jquery json

我希望能够解析JSON数据以放入表中,但我似乎无法弄清楚Ajax数据设置。有谁知道这个设置有什么问题?现在我收到了jQuery错误,我的应用程序停在数据设置...

JSON

{
  "AssetGUID":"00000000-0000-0000-0000-000000000000",
  "AwayForRepair":false,
  "BooleanDataItems":[
     {
       "Column":null,
       "DisplayValue":null,
       "TableName":null,
       "Value":false
     }
],
  "ConditionID":0,
  "DecimalDataItems":[
     {
       "Column":null,
       "DisplayValue":null,
       "TableName":null,
       "Value":0
     }
],
  "DeviceName":null,
  "Faulty":false,
  "ForDisposal":false,
  "ImageDataItems":[
     {
       "Column":null,
       "DisplayValue":null,
       "TableName":null,
       "Value":null
     }
],
   "InspectionDate":"\/Date(-62135596800000+0000)\/",
   "InspectionPassed":false,
   "InspectionType":0,
   "IntegerDataItems":[
     {
       "Column":null,
       "DisplayValue":null,
       "TableName":null,
       "Value":0
     }
],
   "LocationGUID":"00000000-0000-0000-0000-000000000000",
   "StringDataItems":[
     {
        "Column":null,
        "DisplayValue":null,
        "TableName":null,
        "Value":null
     }
],
   "TagTypeID":0,
   "TransactionGUID":null,
   "UserID":0
}

JQuery的:

function runSync() {
    var url = "https://mobisync.assettagz.com/mobilesync.ashx
    function=sendassetinspection&db=dev400&user=qa&password=Z%40oWl9Tbu8YU95FB8%230oB8p%25hnW9%2B0~7CK5%2B21%405~17%24~%233kRd";
    $.ajax({
        type: "POST",
        url: url,
        data: '{"AssetGUID" : "AssetGUIDNumber", "AwayForRepair" : "RepairBoolean", "BooleanDataItems" : [{"Column" : "ColumnValue", "DisplayValue" : "DisplayContents", "TableName" :' +
        '"TableNameValue", "Value" : "ValueBoolean"}], "ConditionId" : "ConditionValue", "DecimalDataItems" : [{"Column" : "ColumnValue", "DisplayValue" : "DisplayContents", "TableName" :' +
        '"TableNameValue", "Value" : "ValueBoolean"}], "DeviceName" : "DeviceNameValue", "Faulty" : "FaultyValue", "ForDisposal" : "ForDisposalValue", "ImageDataItems" : [{"Column" : "ColumnValue", ' +
        '"DisplayValue" : "DisplayContents", "TableName" : "TableNameValue", "Value" : "ValueBoolean"}], "InspectionDate" : "\/Date(1399398811587)\/", "InspectionPassed" : "InspectionValue", ' +
        '"InspectionType" : "TypeValue", "IntegerDataItems" : [{"Column" : "ColumnValue", "DisplayValue" : "DisplayContents", "TableName" : "TableNameValue", "Value" : "ValueBoolean"}], ' +
        '"LocationGUID" : "LocationGUIDNumber", "StringDataItems" : [{"Column" : "ColumnValue", "DisplayValue" : "DisplayContents", "TableName" : "TableNameValue", "Value" : "ValueBoolean"}], ' +
        '"TagTypeId" : "TagTypeIdValue", "TransactionGUID" : "TransactionGUIDValue", "UserId" : "UserIdValue" }',

        success: successHandlerRunSync,
        error: errorHandlerRunSync,
        dataType: "json",
        jsonpCallback: 'parseJSON' // specify the callback name if you're hard-coding it
    });
    $('#jsonMsg').html('Running...');
    $('#jsonRslt').html(' ');
}

1 个答案:

答案 0 :(得分:0)

var url = "https://mobisync.assettagz.com/mobilesync.ashx\n\
function=sendassetinspection&db=dev400&user=qa&password=Z%40oWl9Tbu8YU95FB8%230oB8p%25hnW9%2B0~7CK5%2B21%405~17%24~%233kRd";

- >的 \ n \

@pennstatephil是对的

@Ronnie也是对的