Contact form for mail send:- Can't pass data through the routes url. The mail send doesn't work. Its a toggle form. So, i can catch all data by using ajax but the ajax url can't work that's why i can't get all data. When i click submit button nothing to happen in my code. no errors no output. totally blank results.
Jquery code:- "url: '/html-form'" Not working. This url can't go the routes url. it print the data variable but can't go the set url.
Routes:- This routes are not working? it doesn't print the Hello Text.Cause the Ajax url not working.
Contact Us
<div id="contact_form">
{!! Form::open(['method'=>'post','class' =>'form-horizontal']) !!}
<div class="form-group">
{{--{!! Form::label('name','Your Name:') !!}--}}
{!! Form::text('name', null,
array('id'=>'name','class'=>'form-control','placeholder'=>'Your Name *')) !!}
</div>
<div class="form-group">
{{--{!! Form::label('query','Query Topic:') !!}--}}
{!! Form::text('query',null,['id'=>'query','class'=>'form-control','placeholder'=>'Query Topic'])!!}
</div>
<div class="form-group">
{{--{!! Form::label('query','Query Topic:') !!}--}}
{!! Form::email('email',null,['id'=>'email','class'=>'form-control','placeholder'=>'Your email'])!!}
</div>
<div class="form-group">
{{--{!! Form::label('query','Query Topic:') !!}--}}
{!! Form::text('phone_number',null,['id'=>'phone_number','class'=>'form-control','placeholder'=>'Your phone number *'])!!}
</div>
<div class="form-group">
{{--{!! Form::label('query','Query Topic:') !!}--}}
{!! Form::text('address',null,['id'=>'address','class'=>'form-control','placeholder'=>'Your Address'])!!}
</div>
<div class="form-group">
{{--{!! Form::label('message','Your Message:') !!}--}}
{!! Form::textarea('message',null,['id'=>'message','class'=>'form-control','placeholder'=>'Message','rows'=>8]) !!}
</div>
<div class="form-group button">
{!! Form::button('SEND',['id'=>'submit'])!!}
</div>
{!! Form::close() !!}
</div>
</div>
</pre>
<pre>
$(document).ready(function () {
$("#submit").click(function () {
var data= {
name: $("#name").val(),
query: $("#query").val(),
email: $("#email").val(),
phone_number: $("#phone_number").val(),
address: $("#address").val(),
message: $("#message").val()
};
console.log(data);
$.ajax({
url: '/html-form',
type: 'get',
data: {data: data},
dataType: 'json',
success: function (response) {
console.log(response);
}
});
});
});
</pre>
<pre>
Route::get('/html-form',function (){
json_encode("Hello");
});
</pre>