In the .ready() function 'this' will always be the document object.
I would do what you're trying to do with this [untested]:

$(document).ready(function() {
   $(".module").each(function() {
      var link = $(this).attr("id");
      $(this).load(link);
   });
});



But additionally I would say that storing a URL in an ID is a Bad Thing To
Do (TM) - some of the characters are not valid as part of an ID. You'd be
better storing that information somewhere else. The two alternatives that
spring to mind straight off are:
* use John's Metadata plugin (
http://jquery.com/dev/svn/trunk/plugins/metadata/lib/jQuery/metadata.js?format=txt
)
* add a lookup table in your javascript which maps each .module element's ID
to a particular URL, e.g:

var links = {"module_id_1": "http://blah.com/foo";, "module_id_2": "
http://blah2.com/bar"};


Then the above function would become:

$(document).ready(function() {
   $(".module").each(function() {
      var link = links[$(this).attr("id")];
      $(this).load(link);
   });
});


Hope that helps...
--rob


On 6/19/07, mhand <[EMAIL PROTECTED]> wrote:


I want to load content into div when the page is loading :

here my html :
<div id="http://www.myweb.com/module1"; class="module">
</div>
i tried
        var loadRemoteModule = function() {
                $('.module').ready(function(){
                        var link = $(this).attr("id");
                        $('#'+link).load(link);
                        });
        };
but i get a 0x80070057 exception. Indeed, link is undefined.

how to load the content of http://www.myweb.com/module1 when the div
is ready?

Can you help me?




--
Rob Desbois
Eml: [EMAIL PROTECTED]
Tel: 01452 760631
Mob: 07946 705987
"There's a whale there's a whale there's a whale fish" he cried, and the
whale was in full view.
...Then ooh welcome. Ahhh. Ooh mug welcome.

Reply via email to