weixin_33726318 2015-09-09 15:31 采纳率: 0%
浏览 26

Laravel中的Ajax验证

I am trying to make an ajax veryfication but i do not know why it doesn't work.

This is my ajax script:

<script type="text/javascript" language = "javascript">

function checkWords () {
  var status = document.getElementById("status");
  var u = document.getElementById("styled").value;
  if(u != "")
  {

    status.innerHTML = 'Verifying...';
    var hr = new XMLHttpRequest();
    hr.open("POST","/topicnou",true);
    hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    hr.onreadystatechange = function(){
         if (hr.readyState == 4 && hr.status == 200)
      {status.innerHTML = hr.responseText;}  

}

  var v = "name="+u;
  hr.send(v);


}
}
</script>

This is my php :

<?php 

if(isset($_POST['name']) && $_POST['name'] != ""){

   echo 'succes';

 }

?>

PS: bought scripts are located in TopicNou.blade.php wich is seen if you go to localhost/topicnou.

This is what appears in my console:

POST http://localhost/topicnou 500 (Internal Server Error)

XHR finished loading: POST "http://localhost/topicnou".

  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8
      • ¥15 安卓时间管理APP,怎么做
      • ¥15 这段有什么bug 为什么总报错