Home > Backend Development > PHP Tutorial > 帮小弟我看看ajax提交哪有有关问题

帮小弟我看看ajax提交哪有有关问题

WBOY
Release: 2016-06-13 12:07:22
Original
1061 people have browsed it

帮我看看ajax提交哪有问题

<br />  $.ajax({<br />                type: "post",<br />                url: "nodedo.php",<br />                data: $("#form1").serialize(),<br />                success: function(data) {<br />                    layer.msg('添加成功', 2, 1);<br />                },<br />                error: function(data) {<br />                           layer.msg('添加失败', 2, 2);<br />                    alert(data);<br />                }<br />            })<br />
Copy after login

后台
<br /> $conn  = mysql_connect("localhost","root","");<br />$my_db = mysql_select_db("lyq",$conn);<br />      $account = $_POST['account'];<br />   $sql = "insert into salesman(account) values ('$account')";<br />      $result = mysql_query($sql, $conn);<br />     $userInfo = mysql_fetch_assoc($result);<br />       echo  json_encode($userInfo);<br />
Copy after login


还有一种ajax提交
<br /> $.post(<br />                'nodedo.php',<br />                {<br />                    account:$("#account").val(),<br />                    name:$("#name").val()<br />                    //   name:$("#name").val()<br />                },<br />                function (data) { //回调函数<br />                    var myjson='';<br />                    eval('myjson=' + data + ';');<br />                    alert(data);<br /><br />                }<br />        );<br />
Copy after login

这种哪个地方不对?
------解决思路----------------------
alert(data)
看看才知道
------解决思路----------------------
哪里出问题了?
讲清楚症状,好查找问题。
------解决思路----------------------

引用:
Quote: 引用:

哪里出问题了?
讲清楚症状,好查找问题。

我也不知道哪里出问题了,数据库没有变化,也没有返回值

那你就跟踪下,看看有没能执行到数据库插入的语句,有的话,看看语句是什么,是不是能正确执行的。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template