Jquery from submit does not send input values to controller
I have this hidden form
<form method="POST" action="reviews/rate" class="hidden">
<input type="text" name="id" value="">
</form>
which style is
.hidden {
display: none;
}
and jQuery function which submits form
$('.rate').on('click', function(e){
$('.hidden').append(this).submit();
});
.rate is star radio button. Using its event listener I append radio input to hidden form and sumbit the form
But I am not getting input values.
Here is the output of the request in laravel controller
Request {#42 ▼
#json: null
#convertedFiles: null
#userResolver: Closure {#139 ▶}
#routeResolver: Closure {#141 ▶}
+attributes: ParameterBag {#44 ▼
#parameters: []
}
+request: ParameterBag {#43 ▼
#parameters: array:3 [▼
"_token" => "uVJUAwdUVhukLLFMgy9FIBlGh9LsY836uhjoA0EO"
"id" => "28"
"ratingeyJpdiI6Ijc1R2wyNXYzMVd1QVwvNGZQVERwMXp3PT0iLCJ2YWx1ZSI6IlFRSklDK1NlUlFkcEZMWHVtZWpnNFE9PSIsIm1hYyI6IjhhM2FjODZhZWY0YzNlN2U1ZDYxMTQ0OTljMGViYTg3MmZhMWQ4MGMyOTcxYTgxMzAzMGNiNjgwNzE1YTJmNmQifQ==" => "5"
]
}
+query: ParameterBag {#50 ▶}
+server: ServerBag {#46 ▶}
+files: FileBag {#47 ▶}
+cookies: ParameterBag {#45 ▶}
+headers: HeaderBag {#48 ▶}
#content: null
#languages: null
#charsets: null
#encodings: null
#acceptableContentTypes: null
#pathInfo: "/reviews/rate"
#requestUri: "/reviews/rate"
#baseUrl: ""
#basePath: null
#method: "POST"
#format: null
#session: Store {#169 ▶}
#locale: null
#defaultLocale: "en"
-isHostValid: true
-isForwardedValid: true
basePath: ""
format: "html"
}
At least the id field value should be posted with request because I can see it is in the form input through inspect but its always “28” which is wrong.
I see now the rate is posted correct but id still is not.
from Laravel Questions and Answers https://laravelquestions.com/html/jquery-from-submit-does-not-send-input-values-to-controller/
via Lzo Media
No comments:
Post a Comment