Return to Snippet

Revision: 62734
at March 8, 2013 17:43 by killeralienmonk


Initial Code
<?php
// Set your return content type
header('Content-type: application/xml');

// Website url to open
$daurl = 'http://feeds.feedburner.com/jQueryHowto';

// Get that website's content
$handle = fopen($daurl, "r");

// If there is something, read and return
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
?>

// I named the file proxy.php and made my AJAX request to this url. Here is a jQuery code example:

<script>
$("#rssFeeds").load("path/to/proxy.php", function(){
  // Some callback functions
});
</script>

Initial URL
http://jquery-howto.blogspot.ca/2009/04/cross-domain-ajax-querying-with-jquery.html

Initial Description
<p>JUST TO LET YOU KNOW THIS SNIPPET IS NOT MINE THE LINK IS IN THE URL SECTION. </p>

<p>How to make AJAX queries to domains other then yours. Basically how to achieve cross domain scripting with jQuery. The technique will help you resolve the access to restricted uri denied" code: 101" problem.</p>

<p>Using this method for cross site scripting you will be able to:</p>

<ol>
<li>Make AJAX queries to any domain even those that differ from your own.</li>
<li>Use any of $.get(), $.post(), $.ajax(), $getScript(), etc. jQuery AJAX functions as your query method.</li>
</ol>

<p>You will need to put a proxy to between you and the rest of the world. This cross domain querying solution works because you actually loading the content from your own domain. You request the URL and the proxy script on your server actually loading the content from the internet and passing it over to you.</p>

Initial Title
Cross domain AJAX querying with jQuery

Initial Tags

                                

Initial Language
PHP