无法使用jQuery在XHTML中添加SVG

时间:2014-09-19 10:23:47

标签: javascript jquery xhtml

我正在尝试添加一个在ajax调用div中作为响应收到的SVG字符串。但它不起作用的是我的代码。

main.js

function update() {
    var axis1Value = $('#axis1 :selected').text().trim();
    var axis2Value = $('#axis2 :selected').text().trim();
    var shapeBy =  $('#shape :selected').text().trim();
    var colorBy =  $('#colorField').val();
    var myData = '{ "column_names":["'+axis1Value+'","'+axis2Value+'"], "color_by":"'+colorBy+'","shape_by":"'+shapeBy+'"}';
    $.ajax({
       type: 'POST',
       url: 'http://localhost:9080/sample-demo/api/samplechart/create',
       data: myData,
       success: function(result) {
         console.log(result);
         var el = $('#mychart');
         el.remove();   
         el.append(result); 
       },
       contentType: "application/json",
       dataType: "html"
    });
}

0 个答案:

没有答案