0

I have a problem when using jsonp to API HTTPS website. it will return below

response=1&responsetext=SUCCESS&authcode=123456&transactionid=1592337329&avsresponse=&cvvresponse=&orderid=&type=sale&response_code=100&merchant_defined_field_6=&merchant_defined_field_7=&customer_vault_id=

and this is my code.

function getJSON() {
    $.ajax({
        type: "POST",
        dataType: 'jsonp',
        data:{},
        jsonp: true,
        jsonpCallback: "callbackName",
        url: 'https://secure.equitycommercegateway.com/api/transact.php?username=test123&password=test1234&ccnumber=4111111111111111&ccexp=1012&amount=10.00&type=sale&product_sku_1=monthly&callbackName=?',
        success: function(msg){
            alert(msg);
        }
    });
}

$(document).ready(function(){
    var callbackName = function(data) {
        //alert(data.listing.id );
    }
    getJSON();
});

It shows me a console error, Error to read response text.. and points to (=) symbol right before "SUCCESS" text.

anyone can help me?

T. Junghans
  • 11,385
  • 7
  • 52
  • 75
vantian
  • 848
  • 3
  • 10
  • 25
  • 1
    Well, `response=1&responsetext=SUCCESS...` is not JSONP. It is a query string. Make sure you processing the return value appropriately. – Felix Kling Apr 02 '12 at 00:16
  • The callback function should be global. Otherwise its not reachable from the injected script. Attach it to the window object or define it outside of the brackets. – Sebastian Stiehl Apr 02 '12 at 00:17
  • ok then, how can I solved this? do you have any Idea?.. – vantian Apr 02 '12 at 00:20

1 Answers1

1

It is not possible to make a JSONP POST request see this post.

Community
  • 1
  • 1
Eric Bridger
  • 3,751
  • 1
  • 19
  • 34