![](/img/trans.png)
[英]Why is my Jquery Ajax call not working?(Asp.net MVC C#)
[英]C# ASP.NET MVC jQuery .html() function not working with DevExpress chart data
你好開發者,
我的ajax調用有問題,在成功從我的Action中檢索數據后,jQuery html()函數沒有正確地用更新的html內容替換html(內容是基於partialView的DevExpress圖表,只有圖表在它。
該腳本運行良好,但在開發過程中突然間圖表不再更新。 這是我的代碼。
Changes.cshtml
<script type="text/javascript">
function OnSelectTimescale(s, e){
var chartname = s.uniqueID.split("TimescaleMenu").join("");
var actionname = chartname + "PartialChart";
var url = "/Home/" + actionname + "/";
var container = actionname + "Container";
var chartContainer = actionname + "_IMG";
$.ajax({
type: "POST",
url: url,
data: { timescale: e.item.name },
beforeSend: function () {
console.log(chartname);
console.log(actionname);
console.log(url);
console.log(container);
console.log(chartContainer);
LoadingPanel.ShowInElementByID(chartContainer);
},
success: function (response) {
LoadingPanel.Hide();
$(container).html(response);
}
});
}
</script>
<div id="AnimalChangedByPartialChartContainer">
<div id="AnimalChangedByPartialChart" onmousemove="ASPx.chartMouseMove(event, 'AnimalChangedByPartialChart')" onclick="ASPx.chartClick(event, 'AnimalChangedByPartialChart')" style="height:300px;width:500px;">
<img id="AnimalChangedByPartialChart_IMG" src="/DXB.axd?DXCache=eb3eda3a-8a56-485e-a825-715239856987" alt="The ANIMAL_HISTORY chart showing XML inlees module (PDA2RUMA) series, CRV RsReproduction series, LNV Verblijfplaatsen ophalen series, LNV Verblijfplaatsen correctie series." />
</div>
</div>
</div>
請求網址是正確的,我已對其進行了測試,在網絡控制台中,我可以根據新選擇的時間刻度查看生成的圖表的圖像。
“LoadingPanel.Hide();” 是正確執行的最后一行代碼。 有誰知道為什么
$ container.html(響應); 沒有正確地替換我當前的元素?
我猜你需要將dataType屬性設置為ajax請求,因為它不知道期望什么類型的數據。 數據類型
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.