jquery - Laravel: rendering partial views with AJAX requests -
I am trying to create a single page CRUD application and I am using AJAX with jQuery. In this case, I submit the form and store a new country asynchronously in my database and then present a partial view with new data.
This is my script and method that gets the database from the database and returns a partial view.
$ ('# create-country-form'). Submit (function (event) {$ .post ('/ country / store', $ ('# create (country / all), function (data) {$ (' # -table-table ') empty (); $ ('#' Countries 'append' (data ['html']);});}); event.preventDefault ();}); Classroom Controller Expands Base Controller {Public Function All () {$ countries = Country: : All (); $ Html = visible :: create ('countries.list', compact ('country')) -> render (); return response :: jesone (['html' = & gt; $ html ]);} // ...}
However, I actually consider the use of jQuery in the page view I do not like it, it seems to be Laravel's work.
How can I provide a partial view with Laravel with the use of AJAX, and that function is returned to jQuery ( Attachment)
and empty ()
)
you are confused Are there.
Laravel already partially render you make view :: create
and provided Are returning to $ html
.
Then you are passing the scene rendered for JQuery, which only displays that data - it is not doing any calculation on its own.
Comments
Post a Comment