如何使用MVC ajax在新窗口中打开XML? [英] How to open XML in new window using MVC ajax?

查看:65
本文介绍了如何使用MVC ajax在新窗口中打开XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在新窗口中使用mvc ajax javascript保存或下载选项打开xml内容。



下面是我试过的代码..但它显示没有xml格式的新窗口中的内容。我正在使用序列化生成xml字符串



我尝试过:



I want to open xml content in new window with save or download option using mvc ajax javascript.

Below is the code i have tried..But it displays the content in new window without xml format.I am generating the xml string using serialization

What I have tried:

$.ajax({
              url: 'CreateXML',
              type: 'POST',
              data: JSON.stringify(params),
              contentType: 'application/json; charset=utf-8',
              dataType: "json",
              async: false,
              cache: false,

              success: function (msg) {
                  var newWindow = window.open("","new");
                  newWindow.document.open("text/xml");
                  newWindow.document.write(msg.xmlText);




//var w = window.open();
                   //$(w.document.body).html(msg);</p

推荐答案

.ajax({
url:'CreateXML',
类型:'POST',
数据:JSON.stringify(params),
contentType:'application / json; charset = utf-8',
dataType:json,
async:false,
cache:false,

success:function(msg){
var newWindow = window.open(,new);
newWindow.document.open(text / xml);
newWindow.document.write(msg.xmlText);
.ajax({ url: 'CreateXML', type: 'POST', data: JSON.stringify(params), contentType: 'application/json; charset=utf-8', dataType: "json", async: false, cache: false, success: function (msg) { var newWindow = window.open("","new"); newWindow.document.open("text/xml"); newWindow.document.write(msg.xmlText);




//var w = window.open();
                   //


(w.document.body).html(msg);< / p
(w.document.body).html(msg);</p


这篇关于如何使用MVC ajax在新窗口中打开XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆