2012-12-14 8 views
0

ajax & 웹 서비스에 익숙하지 않습니다. 나는 post 메서드에 대한 ajax 호출을 만들기 위해 노력하고있다. 그러나 나는 아래 오류와 함께지고있다.게시 방법이있는 AJAX 호출

The request sent by the client was syntactically incorrect(). </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":"[email protected]","abteilung":{"id":86,"isDeleted":null,"domainId":0,"parentId":85,"code":"mailCa","description":null},"authenticatedAccess":-1,"emailId":"[email protected]","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":"[email protected]","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":"[email protected]","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 
      }); 

누구든지 알려 주시면 알려주세요. 미리 감사드립니다.

감사 Karthick 당신의 data 재산 주위

+0

크로스 도메인 아약스 호출의 경우 JSONP를 사용할 수 있습니다. 여기에 심판이 있습니다. http://stackoverflow.com/questions/5141531/cross-domain-jquery-ajax-request – Hoque

+1

JavaScript 코드가 작성된 방식으로 실행해서는 안되며, 데이터 행에서 오류가 발생해야합니다. – epascarello

답변

1

따옴표 오류에 있습니다. 당신은 예를 들어

data: {"id": 50, "isDeleted": "N", ... }, 
dataType: 'json', 
etc 
+0

안녕하세요 Phil 위의 사항을 시도했지만 ReferenceError 오류가 발생했습니다. 오류가 정의되지 않았습니다. [Break On This Error] \t 오류 (오류); – Karthick88it

0

시도는 데이터 JSON.stringify를 사용하는 간단한 JS 객체를 전송 서버가 말한다 때, JSON은 "포맷"제대로하지

$.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": "[email protected]", 
      "abteilung": { 
       "id": 86, 
       "isDeleted": null, 
       "domainId": 0, 
       "parentId": 85, 
       "code": "mailCa", 
       "description": null 
      }, 
      "authenticatedAccess": -1, 
      "emailId": "[email protected]", 
      "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": "[email protected]", 
      "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": "[email protected]", 
       "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 
}); 
0

를 전송한다. 예를 들어,

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

합니다 ... "(가) {이 안 전에. (다른 syntatic 오류가있을 수 있습니다.)

당신은 당신의 JSON을 테스트하기 위해 JSON 검사기, 예를 들어 http://jsonlint.com/을 사용할 수 있습니다 . 페이로드 즉, 특정 구문 분석 오류에 대한 더 많은 정보를 줄 것이다

0

을 당신은 당신의 데이터에 정확한 싱글/더블 따옴표를 배치해야합니다. 그런 다음

var yourData = { 
'id': 50, 
'isDeleted': 'N', 
'ownerId': { 
    'id': 32, 
    'fullName': 'mailAss,mailAss', 
    'status': 1, 
    'isDeleted': null, 
    'passWord': '[email protected]', 
    'abteilung': { 
     'id': 86, 
     'isDeleted': null, 
     'domainId': 0, 
     'parentId': 85, 
     'code': 'mailCa', 
     'description': null 
    }, 
    'authenticatedAccess': -1, 
    'emailId': '[email protected]', 
    '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': '[email protected]', 
    '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': '[email protected]', 
     '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" 
...