execute(ar">
当前位置:Gxlcms > PHP教程 > javascript-为什么数据库中显示的是null呢?

javascript-为什么数据库中显示的是null呢?

时间:2021-07-01 10:21:17 帮助过:6人阅读

用ajax提交以后数据库中也多了一条 但是显示是null 这是为什么?我ajax用的不对吗?

t.php

  1. <code>
  2. </code>

ajax.php

  1. <code><!--?php
  2. $pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
  3. $txt=$_POST["txt"];
  4. $stmt=$pdo--->prepare("insert into ajax(txt)values(?)");
  5. $stmt->execute(array($txt));
  6. ?></code>

回复内容:

用ajax提交以后数据库中也多了一条 但是显示是null 这是为什么?我ajax用的不对吗?

t.php

  1. <code>
  2. </code>

ajax.php

  1. <code><!--?php
  2. $pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
  3. $txt=$_POST["txt"];
  4. $stmt=$pdo--->prepare("insert into ajax(txt)values(?)");
  5. $stmt->execute(array($txt));
  6. ?></code>

你好像并没有把数据传到后台吧。

哪里传值了?

send里并没有值,有form表单了就没必要写ajax了把 ,配值target="iframe_name"

人气教程排行