This is my controller :
@Controller
@RequestMapping(value = "/paymentgateway")
public class PaymentGatewayController {
@RequestMapping(value = "/checkPayStatusProposalID/{proposalID}", method = RequestMethod.GET)
@ResponseBody
public PGTransaction checkPayStatusByProposalId(@PathVariable String proposalID) throws Exception {
PGTransaction pgTrans = commservice.fetchPaymetDetailsByProposalID(proposalID);
return pgTrans;
}
}
This is my ajax call by which i am trying to call my handler method in spring controller.
function test(){
var testData = {"proposalID":"123"}
var URL = "http://localhost:8080/ABHI/paymentgateway/checkPayStatusProposalID/123";
$.ajax({
url : URL,
async :false,
type : 'POST',
dataType : 'json',
data: JSON.stringify(testData),
contentType : 'application/json',
mimeType : 'application/json',
crossDomain : true,
success : function(data) {
console.log(JSON.stringify(data,null,4));
alert(data);
},
error : function(data, status, er) {
console.log(JSON.stringify(data,null,4));
console.log("Errors : "); //+data.responseJSON.errorMessage
}
});
}
Error that i am getting on chrome:
jquery.js:4 Failed to load http://localhost:8080/myProject/login/fetchagent: Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
{
"readyState": 0,
"status": 0,
"statusText": "NetworkError: Failed to execute 'send' on 'XMLHttpRequest':
Failed to load 'http://localhost:8080/myProject/paymentgateway/checkPayStatusProposalID/123'."
}
Kindly help me to resolve this. I am stuck in this since 1 day.
0 Answer(s)