Ad

Log File Id Not Created For Error In Laravel

- 1 answer

I have a simple form in my Laravel site for asking questions.

While I have submitted the form using Ajax I have got error in my console like below

GET http://localhost/sencare_v2/ask-question-form-submit?first_name=shbshb&last_name=bhbh&email=hbhbh%40gmail.com&contact=5454&question=hbdndjnkdnjdnkdj&_token=aMg6TGCXdHYpjQ2qZP4RxhEIuTmKUHih6seg5kdm 404 (Not Found)

For getting the details of that error I have visited in my log file in storage/logs...

But no file created regarding this error issue.

html form

<form id="ask_question_form" class="rd-mailform text-left" data-form-output="form-output-global" data-form-type="contact" action="" novalidate="novalidate">
    <input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />
    <div class="range range-xs-center">
        <div class="cell-sm-6">
            <div class="form-group form-group-label-outside">
                <input class="form-control form-control-last-child" id="ask_question_first_name" type="text" name="first-name" data-constraints="@Required" placeholder="First Name"><span class="form-validation"></span>
            </div>
            <div class="form-group form-group-label-outside offset-top-20">
                <input class="form-control form-control-last-child" id="ask_question_email" type="email" name="email" data-constraints="@Email @Required" placeholder="Email"><span class="form-validation"></span>
            </div>
        </div>
        <div class="cell-sm-6 offset-top-20 offset-sm-top-0">
            <div class="form-group form-group-label-outside">
                <input class="form-control form-control-last-child" id="ask_question_last_name" type="text" name="last-name" data-constraints="@Required" placeholder="Last Name"><span class="form-validation"></span>
            </div>
            <div class="form-group form-group-label-outside offset-top-20">
                <input class="form-control form-control-last-child" id="ask_question_contact_no" type="text" name="last-name" data-constraints="@IsNumeric @Required" placeholder="Contact No"><span class="form-validation"></span>
            </div>
        </div>
    </div>
    <div class="form-group form-group-label-outside padding-top-20">
        <textarea class="form-control form-control-last-child" id="ask_question_message" name="message" data-constraints="@Required" style="max-height: 150px;" placeholder="Question"></textarea><span class="form-validation"></span>
    </div>
    <div class="offset-top-18 offset-sm-top-30 text-center text-sm-left">
        <button id="ask_question_submit_button" class="btn btn-ellipse btn-primary" type="button" style="min-width: 130px;">send message</button>
    </div>
</form>

ajax part

$.get('ask-question-form-submit', {'first_name': ask_question_first_name, 'last_name': ask_question_last_name, 'email': ask_question_email, 'contact': ask_question_contact_no, 'question': ask_question_message, '_token':$('input[name=_token]').val()}, function(data)
    {}

web.php inside routes/

Route::get('/ask-question-form-submit/{data}', '[email protected]_question_form');

How to solve this? Anybody help please ?

Thanks in advance

Ad

Answer

Regarding the log issue. It's not there because nothing in Laravel broke down. This is simply js telling you that it didn't find the route you gave it. Wouldn't it be better to submit your form with post request. You would have to change ajax to post and also your route type. Remove the /{data} part and see if it works.

Ad
source: stackoverflow.com
Ad