dongpo8250 2015-01-20 15:34
浏览 120

Laravel + jquery ajax找不到文件的地址

I started to learn Laravel. And displayed a lot of problems. Much too much for a product which should facilitate life. But not about this story is the story.

Laravel 4, jQuery 2

Try to download the content from another file in the main file by pressing a button.

But page javascript thrown "Uncaught ReferenceError: address is not defined"

And the place where you want to retrieve new content upload itself.

Weirdest that another laravel site with the same settings, everything is loading.

Main file with content place and jquery ajax script

$('#lsnbBtnAddHistory').on('click', function() {
    $.get('address-view-history', { aid: aid }, function(result) {
        $('#itemContent').html(result);
    });
});

route.php file

Route::get('/address-view-history/', array(
    'as'    => 'address-view-history-get',
    'uses'  => 'AddressController@getAddressViewHistory'
)); 

Does anybody have an idea why route.php file not found url path.

Edit: I found a solution that works

$.get(
    '{{ URL::asset("/") }}address-view-history', 
    {}, 
    function(result)
    {
        $('#itemContent').html(result);
    }); 

But another laravel folder/page/site with the same settings on the same computer works without {{URL :: asset ("/")}}. Why route.php unable to retrieve and process the "address-view-history"?

  • 写回答

1条回答 默认 最新

  • dongsuiying7773 2015-01-20 15:39
    关注

    I'm not familiar with laravel, but couldn't the issue be related to your URL

    'address-view-history'
    

    that should rather be something along the lines of

    '/address-view-history' or '~/address-view-history'
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable