Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 2 years ago.
0

I think you should call route fist then send to ajax.

var url = {{URL::to(...)}}
$.ajax({
.....
url: url+idtoedit,
......
});

After run you can view source to check called url. If called so error in ajaxx.

Last updated 9 years ago.
0

Without the error message we can just guess... my guess is, that you do not send csrf token in this ajax call

0

@TorchSK +1.

What kind of errors are you getting?

Last updated 9 years ago.
0

I 'm not sending csrf token(I did't know I should, and how to). In laravel 4 it worked as is though. I'm not getting any error. Just nothing happens. I 'm not sure the url that is formated is correct: http://laravel2.dev/admin/categories/26 Shouldn't it be

http://laravel2.dev/classifieds2/app/Http/Controllers/admin
Because my controller dir is:
G:\xampp\htdocs\classifieds2\app\Http\Controllers\admin\CategoriesController.php
DocumentRoot "G:/xampp/htdocs/classifieds2/public"
ServerName laravel2.dev
Last updated 9 years ago.
0

tuyenlaptrinh said:

I think you should call route fist then send to ajax.

var url = {{URL::to(...)}}
$.ajax({
.....
url: url+idtoedit,
......
});

After run you can view source to check called url. If called so error in ajaxx.

It didn't work.

0

I also tried this, unsuccessfully:

var url= "{!!URL::to('admin/categories/" + idtodelete +  "')!!}";
var token = "{!!  csrf_token()   !!}";                       

$.ajax({            
    type: 'POST',
    url:url,
    data: {_method: 'delete', _token :token},
    success:function(result){
        alert('success');
    }
});

Also with type: 'DELETE' failed.

Last updated 9 years ago.
0

panosss, we need to see the error... If you have chrome, just open F12, click on "Network" tab and initiate the ajax call. There will be new entry with http://laravel2.dev/admin/categories/{id} URL.

Click on it and on the right panel in the response tab there will be error message.

If you have some other browsers, there are similar tools. Google how to catch ajax calls in your browser.

Last updated 9 years ago.
0

Well...I found out something:

<script src="{{asset('assets/js/jquery.min.js" type="text/javascript')}}"></script>

This produced:

 <script src="http://laravel2.dev/assets/js/jquery.min.js& quot ; type=& quot ;text/javascript"></scr 

Notice the "& quot ;", the quotation mark. (I 've put spaces, the forum deletes them).

I replaced double curly braces with "{!! !!}" and works!!

So I suppose I must have some other problem. Shouldn't it work with "{{ }}"?

Last updated 9 years ago.
0

L4 didn't escape "{{", but L5 does. See the following:

From http://laravel.com/docs/5.0/upgrade

Blade Tag Changes

For better security by default, Laravel 5.0 escapes all output from both the {{ }} and {{{ }}} Blade directives. A new {!! !!} directive has been introduced to display raw, unescaped output. The most secure option when upgrading your application is to only use the new {!! !!} directive when you are certain that it is safe to display raw output.

However, if you must use the old Blade syntax, add the following lines at the bottom of AppServiceProvider@register:

\Blade::setRawTags('{{', '}}');
\Blade::setContentTags('{{{', '}}}');
\Blade::setEscapedContentTags('{{{', '}}}');

This should not be done lightly, and may make your application more vulnerable to XSS exploits. Also, comments with {{-- will no longer work.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

panosss panosss Joined 18 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.