0

私は ajax と Web サービスに少し慣れていません。post メソッドの ajax 呼び出しを実行しようとしています。しかし、私は以下のエラーが発生しています。

クライアントから送信されたリクエストは、構文的に正しくありません ()。</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.25</h3></body></html>

しかし、GET メソッドは完全に機能しています。これは私が試した私のコードです。

 $.ajax({
                type: "POST", //GET or POST or PUT or DELETE verb
                url: "http://88.80.223.163:8080/lumiin-service/lumiin/control/eventmap/add", // Location of the service
                data: "{"id":50,"isDeleted":"N","ownerId":{"id":32,"fullName":"mailAss,mailAss","status":1,"isDeleted":null,"passWord":"chandra20@gmail.com","abteilung":{"id":86,"isDeleted":null,"domainId":0,"parentId":85,"code":"mailCa","description":null},"authenticatedAccess":-1,"emailId":"chandra20@gmail.com1","uuid":"5988371662040","userCode":"mailAss","localOrg":null,"industryTypeId":{"name":"INSR","id":1,"isDeleted":"N","description":"Insurance"},"memeber":false,"profileType":"CA","lastName":"mailAss","firstName":"mailAss"},"prospectId":{"id":158,"isDeleted":"N","yearofBirth":null,"annualRevenue":0,"nationalityId":{"name":"CH","id":1,"isDeleted":"N","description":"Switzerland"},"titleId":{"name":"Mr","id":1,"isDeleted":"N","description":"Mr"},"maritalstatusId":null,"residencyId":null,"languageId":null,"priorityId":{"name":"High","id":2,"isDeleted":"N","description":"High"},"genderId":null,"abteilung":{"id":86,"isDeleted":null,"domainId":0,"parentId":85,"code":"mailCa","description":null},"emailId":"skmvilla@gmail.com","ownerId":{"id":31,"fullName":"mailCa,mailCa","status":0,"isDeleted":"N","passWord":"mailCa","abteilung":{"id":86,"isDeleted":null,"domainId":0,"parentId":85,"code":"mailCa","description":null},"authenticatedAccess":-1,"emailId":"chandra20@gmail.com1","uuid":null,"userCode":"mailCa","localOrg":null,"industryTypeId":{"name":"INSR","id":1,"isDeleted":"N","description":"Insurance"},"memeber":false,"profileType":"Manager","lastName":"mailCa","firstName":"mailCa"},"company":"company","statusId":{"name":"New","id":1,"isDeleted":"N","description":"New"},"startDate":null,"endDate":null,"lastName":"Search","firstName":"Search"},"eventId":{"URL":null,"location":null,"url":null,"id":92,"type":{"name":"govinda","id":20,"isDeleted":"N","description":"desc"},"isDeleted":"N","followUp":null,"countryId":null,"budget":0,"abteilung":{"id":86,"isDeleted":null,"domainId":0,"parentId":85,"code":"mailCa","description":null},"startDate":1337731200000,"endDate":1338422400000,"prospectId":null,"person":null,"eventName":"eeee-updated","place":null,"description":null}}", //Data sent to server                         
               //contentType: "application/json", // content type sent to server
                dataType: "json", //Expected data format from server
                processdata: true, //True or False
                success: function (json) {//On Successfull service call
                    //shell.loaded();
                    alert("cross domain ajax success full.");

                    var result = json.id;
                    alert("result===" + result);
                    $("#dvAjax").html(result);
                },
                error: ServiceFailed// When Service call fails
            });

知っている方はお知らせください。前もって感謝します。

よろしくカーシック

4

4 に答える 4

1

dataプロパティを囲む引用符に誤りがあります。シンプルな JS オブジェクトを送信するだけです。

data: {"id": 50, "isDeleted": "N", ... },
dataType: 'json',
etc
于 2012-12-14T03:41:29.457 に答える
0

データに正しい一重/二重引用符を配置する必要があります。

var yourData = {
'id': 50,
'isDeleted': 'N',
'ownerId': {
    'id': 32,
    'fullName': 'mailAss,mailAss',
    'status': 1,
    'isDeleted': null,
    'passWord': 'chandra20@gmail.com',
    'abteilung': {
        'id': 86,
        'isDeleted': null,
        'domainId': 0,
        'parentId': 85,
        'code': 'mailCa',
        'description': null
    },
    'authenticatedAccess': -1,
    'emailId': 'chandra20@gmail.com1',
    'uuid': '5988371662040',
    'userCode': 'mailAss',
    'localOrg': null,
    'industryTypeId': {
        'name': 'INSR',
        'id': 1,
        'isDeleted': 'N',
        'description': 'Insurance'
    },
    'memeber': false,
    'profileType': 'CA',
    'lastName': 'mailAss',
    'firstName': 'mailAss'
},
'prospectId': {
    'id': 158,
    'isDeleted': 'N',
    'yearofBirth': null,
    'annualRevenue': 0,
    'nationalityId': {
        'name': 'CH',
        'id': 1,
        'isDeleted': 'N',
        'description': 'Switzerland'
    },
    'titleId': {
        'name': 'Mr',
        'id': 1,
        'isDeleted': 'N',
        'description': 'Mr'
    },
    'maritalstatusId': null,
    'residencyId': null,
    'languageId': null,
    'priorityId': {
        'name': 'High',
        'id': 2,
        'isDeleted': 'N',
        'description': 'High'
    },
    'genderId': null,
    'abteilung': {
        'id': 86,
        'isDeleted': null,
        'domainId': 0,
        'parentId': 85,
        'code': 'mailCa',
        'description': null
    },
    'emailId': 'skmvilla@gmail.com',
    'ownerId': {
        'id': 31,
        'fullName': 'mailCa,mailCa',
        'status': 0,
        'isDeleted': 'N',
        'passWord': 'mailCa',
        'abteilung': {
            'id': 86,
            'isDeleted': null,
            'domainId': 0,
            'parentId': 85,
            'code': 'mailCa',
            'description': null
        },
        'authenticatedAccess': -1,
        'emailId': 'chandra20@gmail.com1',
        'uuid': null,
        'userCode': 'mailCa',
        'localOrg': null,
        'industryTypeId': {
            'name': 'INSR',
            'id': 1,
            'isDeleted': 'N',
            'description': 'Insurance'
        },
        'memeber': false,
        'profileType': 'Manager',
        'lastName': 'mailCa',
        'firstName': 'mailCa'
    },
    'company': 'company',
    'statusId': {
        'name': 'New',
        'id': 1,
        'isDeleted': 'N',
        'description': 'New'
    },
    'startDate': null,
    'endDate': null,
    'lastName': 'Search',
    'firstName': 'Search'
},
'eventId': {
    'URL': null,
    'location': null,
    'url': null,
    'id': 92,
    'type': {
        'name': 'govinda',
        'id': 20,
        'isDeleted': 'N',
        'description': 'desc'
    },
    'isDeleted': 'N',
    'followUp': null,
    'countryId': null,
    'budget': 0,
    'abteilung': {
        'id': 86,
        'isDeleted': null,
        'domainId': 0,
        'parentId': 85,
        'code': 'mailCa',
        'description': null
    },
    'startDate': 1337731200000,
    'endDate': 1338422400000,
    'prospectId': null,
    'person': null,
    'eventName': 'eeee-updated',
    'place': null,
    'description': null
}
};

次に使用します。

...
data: yourData,
contentType: "application/json"
...
于 2012-12-14T03:57:29.107 に答える
0

サーバーが言うように、JSON は正しく「フォーマット」されていません。例えば、

 data: "{"id":50,"isDeleted":"N"

... { の前の " があってはなりません。 (他の構文エラーがあるかもしれません。)

http://jsonlint.com/などの JSON バリデーターを使用して、JSON ペイロードをテストできます。これにより、特定の解析エラーに関する詳細が得られます。

于 2012-12-14T03:46:39.383 に答える
0

送信されたデータに JSON.stringify を使用してみてください

$.ajax({
    type: "POST", //GET or POST or PUT or DELETE verb 
    url: "http://88.80.223.163:8080/lumiin-service/lumiin/control/eventmap/add", // Location of the service 
    data: JSON.stringify({
        "id": 50,
        "isDeleted": "N",
        "ownerId": {
            "id": 32,
            "fullName": "mailAss,mailAss",
            "status": 1,
            "isDeleted": null,
            "passWord": "chandra20@gmail.com",
            "abteilung": {
                "id": 86,
                "isDeleted": null,
                "domainId": 0,
                "parentId": 85,
                "code": "mailCa",
                "description": null
            },
            "authenticatedAccess": -1,
            "emailId": "chandra20@gmail.com1",
            "uuid": "5988371662040",
            "userCode": "mailAss",
            "localOrg": null,
            "industryTypeId": {
                "name": "INSR",
                "id": 1,
                "isDeleted": "N",
                "description": "Insurance"
            },
            "memeber": false,
            "profileType": "CA",
            "lastName": "mailAss",
            "firstName": "mailAss"
        },
        "prospectId": {
            "id": 158,
            "isDeleted": "N",
            "yearofBirth": null,
            "annualRevenue": 0,
            "nationalityId": {
                "name": "CH",
                "id": 1,
                "isDeleted": "N",
                "description": "Switzerland"
            },
            "titleId": {
                "name": "Mr",
                "id": 1,
                "isDeleted": "N",
                "description": "Mr"
            },
            "maritalstatusId": null,
            "residencyId": null,
            "languageId": null,
            "priorityId": {
                "name": "High",
                "id": 2,
                "isDeleted": "N",
                "description": "High"
            },
            "genderId": null,
            "abteilung": {
                "id": 86,
                "isDeleted": null,
                "domainId": 0,
                "parentId": 85,
                "code": "mailCa",
                "description": null
            },
            "emailId": "skmvilla@gmail.com",
            "ownerId": {
                "id": 31,
                "fullName": "mailCa,mailCa",
                "status": 0,
                "isDeleted": "N",
                "passWord": "mailCa",
                "abteilung": {
                    "id": 86,
                    "isDeleted": null,
                    "domainId": 0,
                    "parentId": 85,
                    "code": "mailCa",
                    "description": null
                },
                "authenticatedAccess": -1,
                "emailId": "chandra20@gmail.com1",
                "uuid": null,
                "userCode": "mailCa",
                "localOrg": null,
                "industryTypeId": {
                    "name": "INSR",
                    "id": 1,
                    "isDeleted": "N",
                    "description": "Insurance"
                },
                "memeber": false,
                "profileType": "Manager",
                "lastName": "mailCa",
                "firstName": "mailCa"
            },
            "company": "company",
            "statusId": {
                "name": "New",
                "id": 1,
                "isDeleted": "N",
                "description": "New"
            },
            "startDate": null,
            "endDate": null,
            "lastName": "Search",
            "firstName": "Search"
        },
        "eventId": {
            "URL": null,
            "location": null,
            "url": null,
            "id": 92,
            "type": {
                "name": "govinda",
                "id": 20,
                "isDeleted": "N",
                "description": "desc"
            },
            "isDeleted": "N",
            "followUp": null,
            "countryId": null,
            "budget": 0,
            "abteilung": {
                "id": 86,
                "isDeleted": null,
                "domainId": 0,
                "parentId": 85,
                "code": "mailCa",
                "description": null
            },
            "startDate": 1337731200000,
            "endDate": 1338422400000,
            "prospectId": null,
            "person": null,
            "eventName": "eeee-updated",
            "place": null,
            "description": null
        }
    }), //Data sent to server
    contentType: "application/json", // content type sent to server 
    dataType: "json", //Expected data format from server 
    processdata: true,  //True or False 

    success: function(json) { //On Successfull service call 
        //shell.loaded(); 
        // alert("cross domain ajax success full.");

        var result = json.id;
        alert("result===" + result);
        // $("#dvAjax").html(result);
    },
    error: ServiceFailed // When Service call fails
});
于 2012-12-14T03:44:17.257 に答える