我的脚本有问题,请看一下。
我的Javascript
public class SpringInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { SpringConfiguration.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
registration.setMultipartConfig(getMultipartConfigElement());
}
private MultipartConfigElement getMultipartConfigElement() {
MultipartConfigElement multipartConfigElement = new MultipartConfigElement( LOCATION, MAX_FILE_SIZE, MAX_REQUEST_SIZE, FILE_SIZE_THRESHOLD);
return multipartConfigElement;
}
private static final String LOCATION = System.getenv("TEMP").replace('\\', '/') + "/"; // Temporary location where files will be stored
private static final long MAX_FILE_SIZE = 5242880; // 5MB : Max file size.
// Beyond that size spring will throw exception.
private static final long MAX_REQUEST_SIZE = 20971520; // 20MB : Total request size containing Multi part.
private static final int FILE_SIZE_THRESHOLD = 0; // Size threshold after which files will be written to disk
}
我的HTML
<script type="text/javascript">
$(document).ready(function()
{
$("#datetimepicker_mask2").change(function()
{
var tanggalnya = $("#datetimepicker_mask2").val();
$.ajax({
type: "POST",
url: "http://localhost:84/helpdesk2/forgot_password/check_date/"+tanggalnya,
success: function(msgtgl){
if(msgtgl === 'benar' ){
console.log(msgtgl);
$('#form_email').show();
}
else
{
console.log(msgtgl);
$('#form_email').hide();;
}
}
});
return false;
});
});
</script>
我的PHP
<div class="login-box-body">
<div id="form_email">
<form action="http://localhost:84/helpdesk2/forgot_password/check_date/" method="post">
<div class="form-group has-feedback">
<input class="form-control" id="email" placeholder="email@domain.com" name="email" />
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
</div>
<div id="hasiltanggal"></div>
</div>
注意:function check_date($tanggalnya)
{
extract(PopulateForm());
$nipnya = $this->session->userdata('nip');
$hasil = $this->db->query("SELECT BirthDate from Employee where Nip = '".$nipnya."'")->row();
if(indo_date($hasil->BirthDate)==indo_date($tanggalnya))
{
echo "benar";
}
else
{
echo "salah";
}
}
是我处理输入的助手之一。
我无法显示我的populateform()
。我想知道为什么,因为在form_email
我收到了console.log(msgtgl)
。那么,benar
应该出现,对吧?
答案 0 :(得分:1)
我在比较返回的数据方面遇到了类似的问题 - 出于某种原因,我必须在比较值之前对其应用trim(),请尝试以下方法:
if(msgtgl.trim() === 'benar' ){...
或
var test=msgtgl.trim();
if(test=== 'benar' ){...