删除2个请求

时间:2016-10-21 10:45:00

标签: php jquery ajax laravel routes

我使用ajax发出删除请求,但由于某种原因,在向正确的路由发出第一个请求后,它会向当前路由发出另一个请求。我只是将提交到/ products / id的路由,而不是当前路由是/ galleries / id

我的ajax是:

public function destroy($id)
    {
        $product = PhotoGallery::find($id);  
        $product->delete();
        Session::flash('success', 'The product was successfull deleted');
        return back();
    }

删除控制器:

Route::delete('products/{id}', 'PhotoGalleryController@destroy');

路线:

<form method="POST"  id="myform" action="/galleries/{{$gallery->id}}"  class="" role="form"  enctype="multipart/form-data" >
                        {{ method_field('PUT') }}
                        {{csrf_field()}}

注意:在ajax中删除的产品是表单内的产品列表

   private void sndRecMail(){
    btnSend = (Button) findViewById(R.id.send);
    btnSend.setVisibility(View.VISIBLE);

    btnSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            String subject = "file vendors";

            Intent email = new Intent(Intent.ACTION_SEND);
            email.setType("*/*");
            email.putExtra(Intent.EXTRA_EMAIL, new String[]{"xxxxxxx@yahoo.fr"});
            email.putExtra(Intent.EXTRA_SUBJECT, subject);
            email.putExtra(Intent.EXTRA_TEXT, message);

            String dir = context.getFilesDir().getAbsolutePath();
            fi = new File(dir, "vendors.txt");
            if (!fi.exists() || !fi.canRead())
                return;

            readFile();  // check if file is not empty and readable!!!

            Uri uri = Uri.fromFile(fi);
            email.putExtra(Intent.EXTRA_STREAM, uri);
            startActivity(Intent.createChooser(email, "Select Email Client"));

        }
    });

}

0 个答案:

没有答案