ajax part:
$.ajax({
type:"post",
url:"{:url('Contact/sendEmail')}",
data: "username=" $("#username").val(),
//dataType:'json',
success: function (data) {
alert(data);
}
})
thinkphp part:
//Send email
public function sendEmail(Request $request){
$data = $request->param(); //Return information
$name = $data['username'];
Supplement: There is no problem with the path, and request
is also used to report error:
Not yet Define array index: username
路过2018-04-26 08:29:21
data:{
'username' : $("#username").val()
}
In ajax, data is replaced with an object ? ? ?
oswell2018-04-25 13:54:17
Is there a value in Form Data