laravel no response with ajax - Stack Overflow
高洛峰
高洛峰 2017-05-24 11:32:29
0
3
570
@extends('layouts.app') @section('content') {{--

{{$news}}

--}}

@endsection
public function store(Request $request) { $user = Auth::user(); $this->validate($request,[ 'title'=>'required', 'tcontent'=>'required' ]); $news = new News(); $news->title = $request->get('title'); $news->content = $request->get('tcontent'); $news->author = $user->name; $news->save(); return $news; }
Auth::routes(); Route::get('/','HomeController@index')->name('home.page'); Route::group(['prefix'=>'back'], function (){ Route::resource('/news/news','News\NewsController'); Route::group(['prefix'=>'commodity', 'namespace'=>'commodity'], function (){ Route::resource('/classify','ClassifyController'); Route::resource('/commodity','CommodityController'); }); });

The code is as above, nothing happens when clicking the submit button, and no records are inserted into the database. jQuery has also been introduced in the header of the parent page. The page code, controller, and routing settings are as above. I really don’t know what went wrong. Please give the answers

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all (3)
Peter_Zhu

The problem has been solved
1.$('submit') is missing a # number and cannot be retrieved. It should be $('#submit')
2.url should be /back/news/news

    PHPzhong

    The URL is wrong.
    In addition, open the console.log and take a look at the error report and it will be resolved.

      漂亮男人

      It should be that js did not obtain the clicked or submitted object. When encountering ajax problems, you generally need to look at the console and network to analyze whether there are network requests, as well as the request and response information.

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!