douluhaikao93943 2016-10-19 14:53
浏览 281

通过Laravel返回Javascript文件

I am looking to return a Javascript file when a customer goes to a specific URL on my Laravel development. I will run a check against a DB table before showing the Javascript file;

  1. User visits http://www.website.co.uk/account/123542/javascript.js
  2. Laravel checks against the DB to see if 123542 exists as an account
  3. If it exists then return javascript.js if not return error.

The javascript file will be the same no matter what URL is requested so I just need to return a JS file.

I just need to know how to return the Javascript file.

  • 写回答

1条回答 默认 最新

  • dpbf62565 2016-10-19 15:09
    关注

    Try this:

    Route::get('account/{id}/javascript.js', function ($id) {
    
        if (/* the ID exists in the database */ === false) {
            abort(403, 'Forbidden');
        }
    
    });
    

    Did not test it, but it should abort the call if the ID is non-existent, and show the JS otherwise.

    You need the check-the-database logic here of course.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?