Ajax replace text with image

后端 未结 2 530
心在旅途
心在旅途 2021-01-26 04:17

I have put together the following mootools script

 window.addEvent(\'domready\', function() {
    var shouts = \"timed.php\";
    var log = $(\'log_res\');
    f         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-26 04:39

    With MooTools 1.2, this works as requested:

    function updateData (url, target)
    {
      var target = $(target);
      target.empty().addClass('ajax-loading');
      target.innerHTML = "Loading...";
      new Request({
        url: url, 
        method: 'get',
        onComplete: function(responseText) {
          target.removeClass('ajax-loading');
          target.innerHTML = responseText;
        }
      }).send();
    }
    

    Since you are no fun and use MooTools 1.1, I must dig a little... Actually, I got it working using nearly the same setup as you have (notice I use target instead of log, which was defined outside of the scope of this function):

    function updateData (url, target)
    {
      var target = $(target);
      target.empty().addClass('ajax-loading');
      target.innerHTML = "Loading...";
      new Ajax(url, {
        method: 'get',
        update: target,
        onComplete: function() {
          target.removeClass('ajax-loading');
        }
      }).request();
    }
    

提交回复
热议问题