jQuery-AJAX load()方法帮助

I need to get content from an external page and pass it as an argument to a function. I have looked into the url() method in the JQuery documentation but it seems it's only possible to use it to insert external content into div or some other HTML element.

Basically what I need to do is:

// I need to insert external page's content into the cont variable, how to do that?
var cont;
// so I can pass it to the bt() function (it's a tooltip plugin)
$('.class').bt(cont, {
    fill: '#2a4d6b',
    cssStyles: {color: 'orange', fontWeight: 'bold', width: 'auto'}
});

Can anyone tell me if something like that is possible?

$.load("http://someplace", function(data){
    $('.class').bt(data, {
        fill: '#2a4d6b',
        cssStyles: {color: 'orange', fontWeight: 'bold', width: 'auto'}
    });
});

no?

also by external, how external? you cant get anything from another domain, otherwise that will work

It should be possible. What should work (I haven't tried this myself) is to make a hidden IFRAME on the page. Then, set it's src to the URL you need to get, then use the DOM to access the IFRAME's contents. Comment back on this if any of that seems unclear to you.

You want to use .get (http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype) insetad of load. It takes a callback function as an argument. The below will load a link and display it in an alert.

$.get('http://your.website.com/page.html', 
  function (data) {  alert(data) } );

your example rewritten:

$.get('http://your.website.com/page.html', 
      function (data) {  setClass(data); });

function setClass(cont) {
    $('.class').bt(cont, {
        fill: '#2a4d6b',
        cssStyles: {color: 'orange', fontWeight: 'bold', width: 'auto'}  
    });
}