Reputation: 623
I am little bit new to ajax & web services. i am trying to make a ajax call for post method. But i am getting with the below error.
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>
But the GET method is working perfectly. This is my code i have tried out.
$.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
});
if anyone knows please inform. thanks in advance.
Regards Karthick
Upvotes: 0
Views: 842
Reputation: 3956
You need to place correct single/double quotes in your data:
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
}
};
Then use:
...
data: yourData,
contentType: "application/json"
...
Upvotes: 0
Reputation: 633
As the server says, the JSON is not correctly "formatted". For example,
data: "{"id":50,"isDeleted":"N"
... the " before the { should not be there. (There may be other syntatic errors.)
You can use a JSON validator, e.g. http://jsonlint.com/, to test your JSON payload. That will give you more details about the specific parse errors.
Upvotes: 0
Reputation: 13966
Try to use JSON.stringify for the data sent
$.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
});
Upvotes: 0
Reputation: 164731
The quotes around your data
property are in error. You should just send a simple JS object, eg
data: {"id": 50, "isDeleted": "N", ... },
dataType: 'json',
etc
Upvotes: 1