Send XML in a js variable to FusionCharts

吃可爱长大的小学妹 提交于 2019-12-12 04:47:55

问题


Hi I have this php code which ends up with xml data in a string, I then use onClick to send it to a js function

$strXML = "<chart><set label='B' value='12' /><set label='C' value='10'/></chart>"

<td align='right' onClick='drawchart($strXML)' >&pound $totalcost  </td>

However when it gets to my js function it does not work and the data is corrupt

function drawchart(dataX) {
var chart1 = new FusionCharts("../charts/Pie3D.swf", "chart1Id", "400", "300", "0", "1"); 

         chart1.setDataXML(dataX);
         chart1.render("chart1div");
}

Can anyone tell me how to correctly send the xml data via a js variable ?

Thanks


回答1:


Looks to me like you are getting mixed js and php. I'd say you need to quote the data:

onClick='drawchart("$strXML");'

Also, you should probably need to escape all that XML data to avoid the corruption.



来源:https://stackoverflow.com/questions/1734555/send-xml-in-a-js-variable-to-fusioncharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!