0
我的ASP.NET MVC4控制器返回一個XML字符串,當我們通過它SERIAL。現在,當我使用C#發送一個請求,它工作正常,XML字符串回來,看起來像如何使用jQuery提取XML標籤內容?
<CalculatedCode> 12312312 </CalculatedCode>
我需要通過jQuery也做像下面。查詢正在工作,但它返回XMLDocumentObject
,而不是xml string
。我看着jquery文檔來解析它,但我是jquery noob,我確信我在代碼中發生錯誤。
$.ajax({
url: '@Url.Action("Index", "Home")',
type: 'GET',
dataType: 'xml',
data: { SERIAL: serial}, //SERIAL comes from a textbox
success: function (responseData) {
//Code below is messed up, it simply needs to find the CalculatedCode tag
//and extract the value within this tag
xmlDoc = $.parseXML(response);
$xml = $(xmlDoc);
$thecode = $xml.find("CalculatedCode");
// ToDo: Bug stackoverflow members with this noob question
}
});
非常感謝你:)
美麗!像魅力一樣....在10分鐘後會接受。梅西 –