0

We have a HTML form that want we to send to the server. Which sends a script tag like the following:

<div id="14871610107379120"><script type="text/JavaScript" src="https://www.aparat.com/embed/NIM3h?data[rnddiv]=14871610107379120&data[responsive]=yes"></script></div>

I then get an error about this:

MethodNotAllowedHttpException in RouteCollection.php line 218

How can I repair this error?

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Mohammad Ilbeygi
  • 191
  • 3
  • 11

1 Answers1

0

I guess this could be a problem with using PATCH method.

Since you are using a PATCH method. I understand that you have to add an hidden field to your form view so that Laravel can understand that its a patch request and not others:

You can use one of these:

{{ method_field('PATCH') }}

Or this:

<input type="hidden" name="_method" value="PATCH">

But because its already a url, then you can add &_method=PATCH to the url so you'll have:

<div id="14871610107379120"><script type="text/JavaScript" src="https://www.aparat.com/embed/NIM3h?data[rnddiv]=14871610107379120&data[responsive]=yes&_method=PATCH"></script></div>

Hope this helps :)

Note: If the answer I gave is the correct answer then this question is already answered here: MethodNotAllowedHttpException in RouteCollection.php line 219

Community
  • 1
  • 1
  • tanks , but it's not answer !!! this problem just occurred for exist script tag !!! i want insert a script tag to database with form but i can't !!!! – Mohammad Ilbeygi Feb 16 '17 at 14:17
  • Can you add to your controller method to your question perhaps what the problem was may be clearer. – Oluwatobi Samuel Omisakin Feb 16 '17 at 14:22
  • controller method is good , the problem is this that laravel do not allow for sending tag to controller !!!! – Mohammad Ilbeygi Feb 16 '17 at 18:34
  • i do this works : add method_field('PATCH') , add route for patch method , a good controller method , problem is just about this that laravel allow for sending tag to controller !!!! – Mohammad Ilbeygi Feb 16 '17 at 18:39
  • I would say you could exclude the script tag when sending into the db, then whenever you need to retrieve the column where this record is stored, you can concatenate it back with the script tag. What about that? – Oluwatobi Samuel Omisakin Feb 17 '17 at 06:47
  • If you could give an example of how you are sending the script tag to the backend. that is, maybe an example of possible your ajax code and the controller method that receives this request, then it might be possible for me to give a suggesstion – Oluwatobi Samuel Omisakin Feb 17 '17 at 07:08