在 jquery 代码的一部分中,我在下面有这行代码:
var newHtml="<span style='color: green'>"+result.msg+"</span>"
现在 jquery 代码显示在该<body>
部分中,但问题是我在验证中遇到错误:
文档类型在此处不允许元素“span”
我的问题是有没有办法在保留跨度标签的同时修复它,或者我需要使用替代方法吗?
查看源代码的完整代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Edit Assessment Date/Start Time</title>
<link rel="stylesheet" type="text/css" href="edit_sessionadminStyles.css"/>
<link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery-ui-1.8.16.custom.css"/>
<script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui-1.8.16.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery.ui.timepicker.css"/>
<link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery-ui-1.8.14.custom.css"/>
<link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery-ui-timepicker-addon.css"/>
<script type="text/javascript" src="jquery/jquery.ui.timepicker.js"></script>
<script type="text/javascript" src="jquery/jquery-ui-timepicker-addon.js"></script>
</head>
<body>
<script type="text/javascript">
function submitform() {
$.ajax({
type: "POST",
url: "updatedatetime.php",
data: $('#updateForm').serialize(),
dataType:'json', //get response as json
success: function(result){
if(result.errorflag){
//do your stuff on getting error message
var newHtml="<span class='red'>"+result.msg+"</span>";
$("#targetdiv").html(newHtml); //i am displaying the error msg here
}else{
//you got success message
var newHtml="<span class='green'>"+result.msg+"</span>";
$("#targetdiv").html(newHtml);
//Get and store the new date and time.
var newDate = jQuery("#newDate").val();
var newTime = jQuery("#newTime").val();
//Set your current date and time to your new date and time.
jQuery("#currentDate").val(newDate);
jQuery("#currentTime").val(newTime);
//Find the currently selected session and update it.
var selectedOption = jQuery("#sessionsDrop option:selected");
var label = selectedOption.text().split(" - ");
selectedOption.text(label[0] + " - " + newDate + " - " + newTime);
//Clear the new date and time fields.
jQuery("#newDate").val("");
jQuery("#newTime").val("");
$('#targetdiv').show();
}
}
});
}
$('body').on('click', '#updateSubmit', showConfirm);
</script>
<noscript style='color: red'><img src="Images/warning-2.fw.png" alt="Javascript Warning" id="warningImage" name="warningSymbol"/> In order to use this application without any problems, you must have javascript enabled</noscript>
Please Login to Access this Page | <a href='./adminlogin.php'>Login</a>
</body>
</html>