Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to Fix Ajax Call Handler Method in Spring Controller

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.06k
    Answer it

    This is my controller :

    @RequestMapping(value = "/paymentgateway")
    public class PaymentGatewayController {
    @RequestMapping(value = "/checkPayStatusProposalID/{proposalID}", method = RequestMethod.GET)
    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";
                    url : URL,
                    async :false,
                    type : 'POST',
                    dataType : 'json',
                    data: JSON.stringify(testData),
                    contentType : 'application/json',
                    mimeType : 'application/json',
                    crossDomain : true,
                    success : function(data) {	
                    error : function(data, status, er) {
                        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)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: