> 1) This is never working:
> $(window).unload(function() {
> $.get(url);
> });
>
> I simply don't get it to work. How to add an unload-event for
> document/window?
Right now there's some ambiguity between removing a load handler and
adding an unload event, I recommend that you use:
$(window).bind("unload", function ... );
> 2) I have a <div id="nr" class="example"></div>
> The class is at startup invisible (display: none). Now this happens:
> $('#nr').show('slow').load(url).
Easy fix: Make sure that you wait to do the show until after the new
content is loaded:
$("#nr").load(url,function(){
$(this).show('slow');
});
> 3) This is the biggest problem at the moment (for me): I developed an
> AjaxChat, which reloads every few seconds an url with the newest
> messages for the user. I like the idea, to put simple Javascript in this
> delivered content, which is automaticalle evaluated. But jQuery does not
> evaluate it correctly: Variables are not set, I cannot do something like
> this $('id').append("your message: $message"); It's not working. One
> month ago this topic was discussed on the list:
> http://www.mail-archive.com/[email protected]/msg01312.html , but I
> cannot find a solution so far.
Whenever you .load() html the incoming scripts are automatically
evaluated. To make that happen with $.ajax() you need to specify the
dataType property. If you want HTML to come back with embedded
<script> tags, specify it as 'html'. If you're returning nothing but
executable JavaScript, use 'script'.
More info here:
http://jquery.com/api/
Example:
$.ajax({
url: url,
type: "POST",
dataType: "html",
success: function(html) {
// in the SVN version of jQuery html == the returned HTML
// in every other version you need to do this instead:
// html = $.httpData( html, 'html' )
}
});
Hope this helps.
--John
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/