ueen ueen - 25 days ago 5x
Ajax Question

Cross-domain requests with jQuery Plug-In

i need to pull a small string from a diffrent site from a div with the class 'entry' (theres only one div with that class and the div doesnt have an id).
I learned about this plugin http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/
But i somehow did not manage to install nor use the code to make it work.
I tried nothing but the code on the plugin page.
Where/How do i need to install the plugin? Where/How to implement the given code correctly?
Maybe a working fiddle sample would help :)

EDIT: I used this code

<script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script>
<script src="https://raw.githubusercontent.com/padolsey-archive/jquery.fn/master/cross-domain-ajax/jquery.xdomainajax.js"></script>

<script type="text/javascript">
jQuery(document).ready(function() {

url: 'http://news.bbc.co.uk',
type: 'GET',
success: function(res) {
var headline = jQuery(res.responseText).find('a.tsh').text();


And i use phase5 HTML editor, so theres no error thrown, any recommandation for a different editor?
The code just doesnt produce any result, the page loads and functions as normal but no alert is shown.


OK i found a solution, here is what i did: Added header('Access-Control-Allow-Origin: *'); in die functions.php of the wordpress site i want to acess then i used the following ajax request to pull the content:

                  url: 'http://www.somesite.wordpress.com/',
                  type: 'GET',
                  success: function(res) {
                      var data = jQuery.parseHTML(res);  

I tried all of this: Getting specific element from external site using jQuery / ajax and the last answer worked for me (its the same code mentoined above). Unfortunately i dont know why or how this works and if this is the best way, probably not - still it works somehow so thats fine by me. If anyone sees through this and knows a better/sleeker solution, it would be very welcome!