Alright, I have looked around for this problem, but I can only find references to JSON, which I am currently not using. The array value that has a number in it passes, and the DIV updates. However, when ever I try to pass in a string, nothing happens. Here is the code:
<php>
$cont = array();
$cont[] = 'yo';
$cont[] = '2';
foreach($cont as $c){
$statement .= '<button type=\"button\" onclick=\"nFunc('.$c.')\">'.$c.'</button>';
}
</php>
<script>
function nFunc(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","test.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("p="+str);
}
</script>
<div id="myDiv">Default</div>
{$statement}
Please note I am doing testing with AJAX via IP.Board/IP.Content, so the tags and variables in {} are parsed by the IP.C engine.
This code outputs two buttons labeled "yo" and "2". When "2" is clicked, the DIV updates correctly. When "yo" is clicked, nothing occurs.
The test.php file is very simple:
<?php
$hello = $_POST['p'];
echo $hello;
?>
Thanks for any help beforehand.