Javascript Laravel和JQuery URL调用

Javascript Laravel和JQuery URL调用,javascript,php,jquery,laravel,url-routing,Javascript,Php,Jquery,Laravel,Url Routing,我正在尝试从个人资料网站删除图片。上传ist正在工作,但是如果我想删除ajax调用,它将无法正常工作。我是一个拉威尔的初学者,只是随便玩玩 我的头像是: {{ $profileImageSection }} <form name="update-account" action="{{ route('customer.account.profile.action') }}" accept-charset="UTF-8" enctype="multipa

我正在尝试从个人资料网站删除图片。上传ist正在工作,但是如果我想删除ajax调用,它将无法正常工作。我是一个拉威尔的初学者,只是随便玩玩

我的头像是:

    {{ $profileImageSection }}
<form
    name="update-account"
    action="{{ route('customer.account.profile.action') }}"
    accept-charset="UTF-8"
    enctype="multipart/form-data"
    class="with-padding with-validation"
    data-image-action="{{ route('customer.account.profile.image.action') }}"
    data-image-delete="{{ route('customer.account.profile.image.delete') }}">
    <input type="hidden" name="_token" value="{{ csrf_token() }}" />
    <input type="hidden" name="account_type" value="_Private" />
    <div class="holder message"></div>
URL正确,我的路由如下:

    Route::post('/delete', array(
            'as'    => 'customer.account.profile.image.delete',
            'uses'  => 'UserProfileController@postImage'
        ));

但它不起作用。我试了很多,但再也找不到解决办法了。我认为路由没有呼叫。有人能帮我吗?

我看到了几个问题

如果使用(
Form::open()
/
Form::close()
),则不需要手动包含隐藏的CSRF令牌元素。但是,更大的问题是javascript:

$('.profile-image .delete a.delete').click(function() {
    $(this).parent().find('.deletepic').click();
});

$.('form[name=delete-profile-image]')({
    url: $('form[name=update-account]').data('image-delete'),
    type: 'POST',
    dataType: 'json'
});
AJAX调用在哪里?(提示,它不在那里…)当您可以对锚本身发出AJAX调用时,为什么要让锚元素触发对表单中隐藏按钮的单击?尝试将您的HTML更改为以下内容

@if (!empty($image))
    <a href="#" class="delete">Delete</a>
    {{ Form::open(array('url' => route('customer.account.profile.image.delete'), 'style' => 'display: none', 'id' => 'image_delete')) }}
        {{ Form::text('image', $image) }}
    {{ Form::close() }}
@endif

不,只是什么都没发生。哦,我明白了,你当然是对的!谢谢你的快速回复。现在它正在路由到/删除。我只是想打个电话UserProfileController@postImage在/delete下使用ajax。这样用户就不会离开当前站点。喜欢用“Dropzone”上传图像动作“=>”UserProfileController@postImage“没用。现在我怎么称呼它但不离开网站?
$('.profile-image .delete a.delete').click(function() {
    $(this).parent().find('.deletepic').click();
});

$.('form[name=delete-profile-image]')({
    url: $('form[name=update-account]').data('image-delete'),
    type: 'POST',
    dataType: 'json'
});
@if (!empty($image))
    <a href="#" class="delete">Delete</a>
    {{ Form::open(array('url' => route('customer.account.profile.image.delete'), 'style' => 'display: none', 'id' => 'image_delete')) }}
        {{ Form::text('image', $image) }}
    {{ Form::close() }}
@endif
$('.profile-image .delete a.delete').click(function() {
    $('#image_delete').submit()
});