0

I am using 'benalman simple php proxy' to extract json from some cross-origin url,

The problem is that the request is sent, but i can not see it in the console

How can i get the response please?

http://jsfiddle.net/gnpj5csk/309/

var url = 
'http://benalman.com/code/projects/php-simple-proxy/ba-simple-proxy.php?url=http%3A%2F%2F***%3A8080%2F***.php%3Fusername%3D***%26password%3D***';

$.ajax({
'url': url,
'dataType': 'jsonp',
'success': function(response){
 console.log(response);
 }
 });
Scott Weaver
  • 7,192
  • 2
  • 31
  • 43
padusi
  • 35
  • 6

2 Answers2

0

There it a typo in your dataType value "jsonp" should be "json". Also ajax defaults to "get". Maybe you want to change it to "post". I tried it out an can see the logged response-object in my dev tools.

var url = 'http://benalman.com/code/projects/php-simple-proxy/ba-simple-proxy.php?url=http%3A%2F%2F***%3A8080%2F***.php%3Fusername%3D***%26password%3D***';
$.ajax({
'url': url,method: 'post',
'dataType': 'json',
'success': function(response){
         console.log(response);
     }
 });
C4pt4inC4nn4bis
  • 586
  • 1
  • 6
  • 18
  • you tried with the link above? In the link you added, I arranged the information with *** – padusi Jun 23 '18 at 09:26
  • request works and the response object is logged in the console. Off course it shows "statusText": "error" cause of the broken link. So with a valid link & login it should return whatever you trieing to get – C4pt4inC4nn4bis Jun 23 '18 at 09:35
0

It looks like the server is returning straight json, but it should be jsonp as indicated by the request, so your error function is what's being invoked:

var url = 
'http://benalman.com/code/projects/php-simple-proxy/ba-simple-proxy.php?url=http%3A%2F%2F***%3A8080%2F***.php%3Fusername%3D***%26password%3D***';
    $.ajax({
      'url': url,
      'dataType': 'jsonp',
      'success': function(response){
        console.log(response);
      },
      'error': function(xqr, status, error) {
        console.log(error); //this gives "parsererror"
      }
    });
Scott Weaver
  • 7,192
  • 2
  • 31
  • 43