I'm trying to put two onClick functions, but when i put them together I get an error. And first function ain't working, here is my script. As you can see im trying to call insertData function and then reload page with this function window.location.reload(). Bellow the script there is photo with an error.
if ($canEdit) {
$s .= ("\n\t\t".'<a href="#">'
. "\n\t\t\t".'<img src="./images/icons/tick.png" alt="' . $AppUI->_('Check')
. '" border="0" width="12" height="12" onClick="javascript:insertData('. $currentTasken .', '.$currentUser.', \''.$currentSummary.'\', '.$currentPercent.', \''.$currentDescription.'\'); window.location.reload();" />' . "\n\t\t</a>");
}
$s .= "\n\t</td>";
?>
<script type="text/javascript">
// Note that you should use `json_encode` to make sure the data is escaped properly.
var currentTasken = <?php echo json_encode($currentTasken=$a['task_id']); ?>;
var currentUser = <?php echo json_encode($currentUser=$AppUI->user_id); ?>;
var currentSummary = <?php echo json_encode($currentSummary=$row[0]); ?>;
function insertData(currentTasken, currentUser, currentSummary, currentPercent, currentDescription)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("POST","modules/tasks/datafile.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
// Here, use the JS variables but, likewise, make sure they are escaped properly with `encodeURIComponent`
xmlhttp.send("currentUser=" + encodeURIComponent(currentUser) + "¤tTasken=" + encodeURIComponent(currentTasken) + "¤tSummary=" + encodeURIComponent(currentSummary) + "¤tPercent=" + encodeURIComponent(currentPercent)+ "¤tDescription=" + encodeURIComponent(currentDescription));
}
</script>
Here is the photo of the error:
