• 请不要在回答技术问题时复制粘贴 AI 生成的内容
netcan
V2EX  ›  程序员

写了个 Laravel 入门教程: AJAX 的 CRUD 页面

  •  
  •   netcan ·
    netcan · Aug 17, 2016 · 3941 views
    This topic created in 3558 days ago, the information mentioned may be changed or developed.
    Supplement 1  ·  Aug 18, 2016
    博客字体已去掉阴影,代码背景 light
    7 replies    2016-08-21 14:28:07 +08:00
    fhefh
        1
    fhefh  
       Aug 17, 2016
    先 mark 最近在学这个在
    kkk330
        2
    kkk330  
       Aug 17, 2016   ❤️ 1
    laravel 直接 return 默认返回的就是 json, 不用手动 response()->json(), 这点很爽
    netcan
        3
    netcan  
    OP
       Aug 17, 2016
    @kkk330 这样啊, 3Q 。。。我一直 responce()->json()。。。。有空就改改
    cha1
        4
    cha1  
       Aug 17, 2016   ❤️ 1
    跟踪了下源码,挺有意思的。

    Laravel 的返回结果最后都会被包装成 Response 对象。 Response 的 __construct 方法里面,有这么一行 `$this->setContent($content);` 然后再看看 setContent 这个方法,很容易就明白了。

    https://github.com/laravel/framework/blob/5.2/src/Illuminate/Http/Response.php#L43

    这是我摘抄的部分源码:
    https://gist.github.com/zqhong/2b38627ab33536c7dd47c58d48731f66
    xiaome
        5
    xiaome  
       Aug 21, 2016
    转义一下吧。
    https://ooo.0o0.ooo/2016/08/20/57b92d02d00df.png
    netcan
        6
    netcan  
    OP
       Aug 21, 2016
    @xiaome 这个的话,刷新下就没问题了。。。其实是只执行一次的,我去看看 js 怎么转义。。
    netcan
        7
    netcan  
    OP
       Aug 21, 2016
    @xiaome 已转义
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3011 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 02:05 · PVG 10:05 · LAX 19:05 · JFK 22:05
    ♥ Do have faith in what you're doing.