1

I would like to pass data using jQuery into a service which I have created in tibco. is it possible?

The code that I have written returns me a error alert and I am not sure what is wrong.

Update: This is the error I'm getting at the console.

Access to XMLHttpRequest at 'http://swaggerurl/payment' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

        $(document).ready(function() {
            var serviceURL = 'http://swaggerURL/payment';
            jQuery.ajax({
                url: serviceURL,
                type: "post",
                data: {
                        PID: 1,
                        OID: 1,
                        Pstatus: "Complete",
                        price: 20
                    },
                success: function(){
                    alert('success');
                },
                error: function(){
                    alert('failure');
                }
            });
        });
James Z
  • 12,209
  • 10
  • 24
  • 44
sok09
  • 117
  • 9
  • 1
    Are you getting any feedback from the browser's debugging tool console or network tabs? – Doug F Mar 27 '19 at 12:26
  • 1
    This is the feedback I'm getting "Access to XMLHttpRequest has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." – sok09 Mar 27 '19 at 12:32
  • 1
    Then that's your issue. You can read more about it at https://stackoverflow.com/questions/298745/how-do-i-send-a-cross-domain-post-request-via-javascript but you also might want to do some research into Tibco to see what they might have to say. I did find this with a quick search https://docs.tibco.com/pub/api-exchange-gateway/2.2.1/doc/html/GUID-BBB5FF55-75E6-4200-A120-F1AAAB17B833.html – Doug F Mar 27 '19 at 12:37

0 Answers0