0

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 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.