I want to change:
function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
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("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","get_content.php?q="+str,true);
xmlhttp.send();
}
into jQuery ajax. Right now i have the following to achieve that:
$('#menurow').change(function () {
$.ajax({
type: "GET",
url: "get_content.php?q="+str,true,
data: $('#txtHint').innerHTML(),
success: function(data) {
alert('test');
}
})
});
When i try this code out, the browser keeps saying Uncaught SyntaxError: Unexpected identifier on data: $('#txtHint').innerHTML(). Does somebody knows how to fix this? This is the html/php code:
<form>
<select name="menurow" id="#menurow">
<option value ="select">Selecteer een menu</option>
<?php
$sql= mysql_query("SELECT * FROM Menu") or die(mysql_error());
while ($row = mysql_fetch_array($sql))
{
?><option data="menu" value="<?php echo $row['menu_id']; ?>"><?php echo $row['menu_name']; ?></option>
<?php
$subsql= mysql_query("SELECT * FROM SubMenu INNER JOIN Menu WHERE SubMenu.menu_id = Menu.menu_id AND Menu.Menu_id = ".$row['menu_id']."") or die(mysql_error());
while ($subrow = mysql_fetch_array($subsql))
{
?><option data="submenu" value="<?php echo $subrow['submenu_id']; ?>"><?php echo "--".$subrow['submenu_name']; ?></option>
<?php
}
}
?>
</select>
</form>
<div id="txtHint"></div>
Thanks in advance
Thanks for your help guys. Right now i have it as follows:
$('.menurow').change(function(str) {
$.ajax({
type: "GET",
url: "get_content.php?q="+str,
success: function(data) {
$('#txtHint').html(data);
tinyMCE.init({
theme : "advanced",
mode : "textareas"
});
}
})
});
How can i get the data of the form in it? I have declared str in the function. Because of this it is showing empty fields. How can i fill them up with data?
url: "get_content.php?q="+str,true,because of thetrue,it is not a valid object.$('#txtHint').innerHTML()contain?