Problem calling ajax program that makes cross domain call

Problem calling ajax program that makes cross domain call

Hello,

I am using ajax to call a program that makes communication with paypal. 

The program is the paypal api that can be downloaded from paypal. I have a stand-alone version and an CGI version that runs in apache. 
The stand-alone works fine and returns the paypal response. The problem is in the CGI version. The program is completing normally and I am getting the proper response from paypal. But Apache is reporting a 500 error message. But Im getting a success completion and the test-payment is accepted  by paypal

I have a CGI program that makes the call to the paypal API. The API will then open an ssl socket and makes the call to paypal. Paypal then returns the response. After the program receives the response Im am then taking the json response, convert it to a string and display the response in the browser. 
But Im getting the 500 error as the program eceives the response.

I have used debug to find the exact spot when in jquery Im getting the error. Im using version 10.2 and it's occuring at 8706 xhr.send.

Can someone please help.

 $.ajax({                                                                                                         
 type: 'get',                                                                                                     
 async: false,                                                                                                    
 dataType: 'jsonp',                                                                                                
 url:'IPAL03A.PGM',                                                                                               
 data:{port:"TST", SCCUST:$cust, totpra:totprice.toString(), tottxa:tottax.toString(), totsha:totship.toString()},
 fail   : function($ipal){                                                                                        
 console.log('fail: ' + $ipal);                                                                                   
 },                                                                                                               
 error  : function('error: ' + $ipal){                                                                            
 console.log($ipal);                                                                                              
 },                                                                                                               
 success: function($ipal){