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
data:{
'username' : $("#username").val()
}
In ajax, data is replaced with an object ? ? ?
manual
Is there a value in Form Data