Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
等待所有映像加载jQueryAjax/jQueryPJAX_Jquery_Ajax_Pjax - Fatal编程技术网

等待所有映像加载jQueryAjax/jQueryPJAX

等待所有映像加载jQueryAjax/jQueryPJAX,jquery,ajax,pjax,Jquery,Ajax,Pjax,这是我想做的事情的剪贴画 $.pjax = function( options ) { var $container = $(options.container), success = options.success || $.noop // We don't want to let anyone override our success handler. delete options.success // We can't persist $objects us

这是我想做的事情的剪贴画

$.pjax = function( options ) {
  var $container = $(options.container),
      success = options.success || $.noop

  // We don't want to let anyone override our success handler.
  delete options.success

  // We can't persist $objects using the history API so we must use
  // a String selector. Bail if we got anything else.
  if ( typeof options.container !== 'string' )
    throw "pjax container must be a string selector!"

  var defaults = {
    timeout: 650,
    push: true,
    replace: false,
    // We want the browser to maintain two separate internal caches: one for
    // pjax'd partial page loads and one for normal page loads. Without
    // adding this secret parameter, some browsers will often confuse the two.
    data: { _pjax: true },
    type: 'GET',
    dataType: 'html',
    beforeSend: function(xhr){
      $container.trigger('start.pjax')
      xhr.setRequestHeader('X-PJAX', 'true')
    },
    error: function(){
      window.location = options.url
    },
    complete: function(){


$container.trigger('end.pjax')
},
success: function(data){
  // If we got no data or an entire web page, go directly
  // to the page and let normal error handling happen.
  if ( !$.trim(data) || /<html/i.test(data) )
    return window.location = options.url

  // Make it happen.
  // i think im not getting it right.
  $(window).load(
      function() {
          $container.html(data)
      }
  );
就像但它是在jqueryajax请求之后

正如您在底部看到的//实现它,我试图在htmldata中的所有图像都准备好提供后返回htmldata,我们能以某种方式这样做吗

谢谢


Adam Ramadhan

我相信在浏览器开始加载任何图像之前,您必须将加载的HTML插入DOM。您应该能够将其插入隐藏显示:none div,并在该隐藏div上设置.load回调


改进了.load事件,以便在加载图像时更一致地触发它。

我相信在浏览器开始加载任何图像之前,您必须将加载的HTML插入DOM。您应该能够将其插入隐藏显示:none div,并在该隐藏div上设置.load回调

改进.load事件,以便在加载图像时更一致地触发它