Grahame A
Grahame A

Reputation: 3953

AJAX Callback not firing during cross domain request

I have the following script:

var queryString = $("#recurringForm").serialize();

                        var action = "https://www.beanstream.com/scripts/recurring_billing.asp?" + queryString;

                        $.ajax({url : action,
                            type: 'GET', 
                            success : function () {
                                alert("this should be called");
                                submitPayment();
                            }
                        });

Everything here works except for the callback. Is this because I'm posting to a domain different from my own? If so, how do I get around this.

Upvotes: 0

Views: 356

Answers (2)

Jeremy
Jeremy

Reputation: 437

Cross domain calls are blocked by browsers. The only exception to this is JSONP calls. Check out the jQuery docs and consider using .getJSON instead of ajax: http://api.jquery.com/jQuery.getJSON/

Upvotes: 0

VNO
VNO

Reputation: 3695

Yes, it is because it's a different domain. Your browser will not allow it. Instead, you should send an AJAX request to a route on your server, and execute the GET from your server.

Upvotes: 1

Related Questions