Skip to content

Issue in Ajax Call #999

Closed
Closed
@lgchintake

Description

@lgchintake

I am using jQuery v2.1.4.min.js library.

I am calling ajax giving some parameters to it as like following:

First Case

var myData = '{"userId":"abc", "password":"abc??"}';
$.ajax({
	type: "POST",
	url: myUrl,
	data: myData,
	dataType: "json",
	success: function(serviceData) {
		console.log(JSON.stringify(serviceData));
	},
	error: function(err) {
		console.log("Error: "+err);
	}
});

I have given password having two question marks(??) so it is manipulating it automatically as

{"userName":"abc", "password":"abcjQuery21406515378922229067_1479880736745?"}:

When I remove the dataType: "json", it works fine.

Second Case

When I write above code with ContentType as:

var myData = '{"userId":"abc", "password":"abc??"}';
$.ajax({
	type: "POST",
	url: myUrl,
        contentType: "application/json; charset=utf-8",
	data: myData,
	dataType: "json",
	success: function(serviceData) {
		console.log(JSON.stringify(serviceData));
	},
	error: function(err) {
		console.log("Error: "+err);
	}
});

It works fine. No issue.

I am using Java RestEasy Service for handling the ajax requests.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions