With Simple PHP Proxy, your JavaScript can access content in remote webpages, without cross-domain security limitations, even if it's not available in JSONP format. Of course, you'll need to install this PHP script on your server.. but that's a small price to have to pay for this much awesomeness.

Please note that while jQuery is used here, you can use any library you'd like.. or just code your XMLHttpRequest objects by hand, it doesn't matter. This proxy just acts a bridge between the client and server to facilitate cross-domain communication, so the client-side JavaScript is entirely left up to you (but I recommend jQuery's getJSON method because of its simplicity).

Please see the project page and documentation for more usage information.

..or try these sample Remote URLs: GitHub, a sample JSON (not JSONP) request, a 404 error page

Request URL

N/A, click Submit!

Simple PHP Proxy response

N/A, click Submit!

The code

$(function(){
  
  // Handle form submit.
  $('#params').submit(function(){
    var proxy = '../../ba-simple-proxy.php',
      url = proxy + '?' + $('#params').serialize();
    
    // Update some stuff.
    $('#request').html( $('<a/>').attr( 'href', url ).text( url ) );
    $('#response').html( 'Loading...' );
    
    // Test to see if HTML mode.
    if ( /mode=native/.test( url ) ) {
      
      // Make GET request.
      $.get( url, function(data){
        
        $('#response')
          .html( '<pre class="brush:xml"/>' )
          .find( 'pre' )
            .text( data );
        
        SyntaxHighlighter.highlight();
      });
      
    } else {
      
      // Make JSON request.
      $.getJSON( url, function(data){
        
        $('#response')
          .html( '<pre class="brush:js"/>' )
          .find( 'pre' )
            .text( JSON.stringify( data, null, 2 ) );
        
        SyntaxHighlighter.highlight();
      });
    }
    
    // Prevent default form submit action.
    return false;
  });
  
  // Submit the form on page load if ?url= is passed into the example page.
  if ( $('#url').val() !== '' ) {
    $('#params').submit();
  }
  
  // Disable AJAX caching.
  $.ajaxSetup({ cache: false });
  
  // Disable dependent checkboxes as necessary.
  $('input:radio').click(function(){
    var that = $(this),
      c1 = 'dependent-' + that.attr('name'),
      c2 = c1 + '-' + that.val();
    
    that.closest('form')
      .find( '.' + c1 + ' input' )
        .attr( 'disabled', 'disabled' )
        .end()
      .find( '.' + c2 + ' input' )
        .removeAttr( 'disabled' );
  });
  
  // Clicking sample remote urls should populate the "Remote URL" box.
  $('#sample a').click(function(){
    $('#url').val( $(this).attr( 'href' ) );
    return false;
  });
});