2012-03-27 15 views
1

私はjqueryのAjaxの負荷の呼び出しを介して、私のセレクタをロードすると、問題が生じていますが、以下を参照: -jqueryダイアログのajaxがセレクタ(div)ではなくページ全体をプルロードするのはなぜですか?

  var $loading = $ ('<img src="/img/loading.gif" alt="loading">'); 

    $("#addAddressBtn").click(function(){ 

     var $dialog = $('<div></div>') 
       .append($loading.clone()); 

      $dialog.load("/customer/profile#addressSel", [], function(response, status, xhr) { 
        if (status == "error") { 
         var msg = "Sorry but there was an error: "; 
         $dialog.html(msg + xhr.status + " " + xhr.statusText); 
        } 
        else{ 
         $dialog.dialog({ 
          title: "Add Address", 
          width: "auto", 
          height: "auto", 
          modal: "true" 
         }); 
         $dialog.dialog('open'); 
         return false; 
        }; 
      }); 
    });    

私は、ダイアログに表示したいすべてがaddresssSel divの全体プロフィールページがなぜロードされているのですか?

答えて

2

"#"文字の前にスペースを入れる必要があります。

$dialog.load("/customer/profile #addressSel", ... 

は、あなたがこれを行うときがあることに注意してくださいページ断片がロードされ、DOMに追加された後、あなたが選択すること<div><script>タグが実行されないます。

関連する問題