我是laravel的新手,当我使用单击函数提交表单时出现了一些问题。ajax jquery controller不会将数据保存到数据库,每次响应时都会使用整个html文件。请帮帮我。
关于标题的一些信息
请求URL:http://akshay.laravel/patient1?fname=asdknkl
状态代码:200 OK
远程地址:[::1]:80
推荐人策略:降级时无推荐人
缓存控制:无缓存,专用
连接:保持活力
内容类型:text/html;字符集=UTF-8
日期:2018年7月12日星期四10:06:54 GMT
保持存活:超时=5,最大=99
服务器:Apache/2.4。27(Win64)PHP/7.1。9
设置Cookie: XSRF-TOKEN=eyJpdiI6IkFJRU1DQ3JhSWU2aWRMM0RXQlwvd0NBPT0iLCJ2YWx1ZSI6IlpDN2pLdnVXQUV5b0lZRTlBUG95d3N6dDdXZEJ3ajBGU0g1NVwvaEFYak9PampDajcxQmVZVhSZTUrVlNsTHhhbW9RWmdLOWNGWTdJNHpYdUhYV1N0Z09iwibWFjIjoiZDZiNzQyOGU1MWQxN2ZlZGNiZTkyMWU3NmzhYmMyY2FiMTQ5NGNkZDQ2OGQ3MzVlMzVjYjRhY2ZkMWMzNDg0NiJJ
设置-Cookie:
laravel_session=eyJpdiI6IjFVK1RDZFlRajVtcWhcL0twNVhtS0NnPT0iLCJ2YWx1ZSI6IllkWkdSSjlPY3pFeGNKSXBZNjVYRGE0TFU4TWxGZ2hwa3VYOGttdlVM3lSUVFCakZDNFZUZGZkcUY5eFwvWHBOQVdsenY2S09kYlNWUktxY2x3VU1DUT09iwibWFjIjoiN2VhZTEwNTAxY2YxNTZlNDAzJmNTNlYWJhYzcxYjBkY2I0NDZmNTc3N2ViZWU3NmY5Y2NmODg5MzllYWMzNiJ9;到期=周四,12-Jul-2018 12:06:54GMT;
X-Powered-By:PHP/7.1。9
接受:/
接受编码:gzip,deflate
接受语言:en-US,en;q=0.9
连接:保持活力
Cookie:XSRF-TOKEN=EYJPDii6ILBJCVPRGW5VKN2VDVxtuCra1BZWkE9PsisinZHBhLijoiZGHLT2NPC1BjDM1PDG8OthVR1WVbFjMBgDWTG5PC2V1DDNFDLK0EKE0EKE0AFNVT0JTEHJBVzFIAEX2ZKFPK2L5BZDLZDLZZZZYWWWW2RK2WU5HKLZBLZBCKRKBY25QQT09IIBwFJJJJJJJJJJJJJWWZFFZZM5NDKYN2MJJJJJJJZN2MKYN2MKYN4LKNKN2ZHNTJINCJ9;laravel_session=EYJPDii6ijlSjuxngdxzjjtAgptmmnjrfyyake9PsisinzhbhvLijoiryvstkv1pTT3rWnyUyTumxvsn0Fnv1zbzzuk3EdjzmxlketdkqlwWnWnWnWnqcjbgWpjtVvgWftbmrk3vMukLkn3OzerzzzzmjTczTczyqqy9Psi1Hyyyyzyyyyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzy==
主持人:阿克谢。拉维尔
推荐人:http://akshay.laravel/patient1
用户代理: Mozilla/5.0(Windows NT 10.0; Win64; x64)AppleWebKit/537.36(KHTML,像壁虎)Chrome/67.0.3396.99Safari /537.36X-CSRF-TOKEN: PIZIO18bZb7ce2M5taV04daMDFokJEHuIrZ88bkR X-请求-与: XMLHttpRequest
fname:asdknkl
姓名:Nkansd
电邮:knklansnd
性别:男
城市:lknksn
州:克林克纳
出生日期:2011-08-19
血型:AB
描述: asak
php文件:
<form class="needs-validation" novalidate id="patientform">
<div class="form-row">
<div class="col-md-4 mb-3">
<label for="validationTooltip01">First name</label>
<input type="text" class="form-control" id="fname" placeholder="First name" value="" required>
</div>
<div class="col-md-4 mb-3">
<label for="validationTooltip02">Last name</label>
<input type="text" class="form-control" id="lname" placeholder="Last name" value="" required>
</div>
<div class="col-md-4 mb-3">
<label for="validationTooltipUsername">Email</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="validationTooltipUsernamePrepend">@</span>
</div>
<input type="text" class="form-control" id="email" placeholder="" aria-describedby="validationTooltipUsernamePrepend"
required>
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-3 mb-3">
<div class="custom-control custom-radio">
<input type="radio" id="male" name="sex" value="male" class="custom-control-input">
<label class="custom-control-label" for="male">Male</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="female" name="sex" value="female" class="custom-control-input">
<label class="custom-control-label" for="female"> Female</label>
</div>
</div>
@csrf
<div class="col-md-3 mb-3">
<label for="validationTooltip03">City</label>
<input type="text" class="form-control" id="city" placeholder="City" required>
</div>
<div class="col-md-3 mb-3">
<label for="validationTooltip04">State</label>
<input type="text" class="form-control" id="state" placeholder="State" required>
</div>
<div class="col-md-3 mb-3">
<label for="validationTooltip05">DOB</label>
<div class="form-group row">
<div class="col-10">
<input class="form-control" type="date" value="2011-08-19" id="dob">
</div>
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-3 mb-3"> <br><br>
<select class="custom-select" id="bloodtype">
<option selected>Select Blood Type</option>
<option value="AB+">AB+</option>
<option value="AB-">AB-</option>
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="O+">O+</option>
<option value="O-">O-</option>
</select>
</div>
<div class="col-md-9 mb-3">
<label for="exampleFormControlTextarea1">Dieases / Description</label>
<textarea class="form-control" id="description" rows="3"></textarea>
</form>
</div>
</div>
<button class="btn btn-primary" type="submit" id="submitform">Submit form</button>
</form>
控制器:
public function store(Request $request)
{
/* */ //
function randomstring($len)
{
$string = "";
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for($i=0;$i<$len;$i++)
$string.=substr($chars,rand(0,strlen($chars)),1);
return $string;
}
$pid = randomstring(5);
$fname = $request->fname;
$lname = $request->lname;
$email = $request->email;
$sex = $request->sex;
$city = $request->city;
$state = $request->state;
$dob = $request->dob;
$bloodtype = $request->bloodtype;
$description = $request->description;
DB::table('tables')->insert(
['pid' => $pid, 'fname' => $fname,'lname' => $lname,'email' => $email,'sex' => $sex,'city' => $city,'state' => $state,'dob' => $dob,'bloodtype' => $bloodtype,'description' => $description,]
);
// $insert = DB::table('tables')->insert(['fname'=>$fname]);
// echo $insert;
return redirect('table.admin');
}
javascript文件:
$(document).ready(function(){
$( "#submitform" ).click(function() {
var fname = $('#fname').val();
var lname= $('#lname').val();
var email = $('#email').val();
var sex = $('input[name="sex"]:checked').val();
var city = $('#city').val();
var state = $('#state').val();
var dob = $('#dob').val();
var bloodtype = $('#bloodtype').val();
var description = $('#description').val();
$.ajax({
url:"/patient1/",
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data:{
'fname': fname,
'lname': lname,
'email': email,
'sex': sex,
'city': city,
'state': state,
'dob': dob,
'bloodtype': bloodtype,
'description': description
}
});
});
});
事情是这样的 我不知道发生了什么,如果有人能帮忙,我会非常感激的。THX!
本文向大家介绍Android 将数据插入数据库,包括了Android 将数据插入数据库的使用技巧和注意事项,需要的朋友参考一下 示例
所以我想在一个控制器中创建两个存储。当我输入时,我确实返回到索引页面,但我提交的数据不存在。然后我看到了我的本地主机,但是我输入的数据也不在那里。当我输入时,没有错误消息。所以我不知道我的错误在哪里。 这是我的看法 createincome.blade.php 这是我的控制器 财务控制人。php 这是我的路线 web.php
我设法将数据插入身份验证,但无法插入数据库: 代码: 错误: E/AndroidRuntime:致命异常:主进程:com。实例budgetingapp,PID:11507 java。lang.RuntimeException:在类androidx上找到了名称getText的冲突获取程序。appcompat。小装置。AppCompativeText位于com。谷歌。火基。消防商店。util。Cust
问题内容: 我想在我的MySQL数据库中插入整数188和90,但以下代码不起作用: 为什么不起作用? 问题答案: 编辑 为我工作: 在MySQL表;