2011-04-12 73 views
0

我有一個Ajax請求,看起來像這樣,jQuery的AJAX,沒有返回HTML

$("#frmProducts").submit(function(){ 
       var dataSet = $("#frmProducts").serialize(); 
       $.ajax({ 
        url: "<?php echo base_url();?>products/updateBasket", 
        data: dataSet, 
        type: "POST", 
        success: function(html){ 
        $('html, body').animate({scrollTop:0}, 'slow'); 
        $("#bagInfo").load("/checkout/loadCartView"); 
        $('body').append(html); 
        $('#basketoverview').fadeIn(2000); 
        setTimeout(function() { $('#basketoverview').fadeOut(2000).hide(); }, 8000); 
        } 
       }); 
       return false; 
      }); 

這應該對URL的請求,並拉回到一個HTML代碼段,PHP代碼的AJAX呼籲,長相喜歡這個;

function updateBasket() 
{ 
    $this->load->model('Checkout_model'); 
    $this->load->model('Product_model'); 
    $derivativeId = $this->input->post('selDerivative-1'); 
    $quantity = $this->input->post('selQuantity'); 
    $derivative = $this->Product_model->GetProducts(array('pdId' => $derivativeId), 'small'); 

    // Add item to shopping bag. 
    $attributes = $this->Product_model->GetProductDerivatives(array('pdId' => $derivativeId)); 
    $this->Checkout_model->AddProduct($derivative, $attributes, $quantity); 
    $this->data['message'] = 'Item added to Shopping Bag.'; 

    // Update Delivery Price 
    $this->Checkout_model->updateDelivery(49); 

    $this->data['items'] = $this->Checkout_model->GetProducts(); 

    $this->template 
    ->build('checkout/quickbasket', $this->data); 
} 

然而,當我運行的方法,不返回HTML,我想這將是,如果我在我的JavaScript的HTML警告我得到一個黑色的對話框。

任何原因,我做錯了什麼?

+0

你檢查你的請求和響應的HttpFox? – 2011-04-12 12:52:31

+0

'如果我在javascript中提醒html我得到一個黑色的對話框.'這怎麼可能? – 2011-04-12 12:53:00

+0

您可以使用螢火蟲或類似的東西來監控請求並查看它實際返回的內容嗎? – 2011-04-12 12:53:06

回答

1

你試過:

dataType: 'html'