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

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

  •  
  •   netcan ·
    netcan · Aug 17, 2016 · 4286 views
    This topic created in 3739 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
    fhefh
    Aug 17, 2016
    1
    先 mark 最近在学这个在
    kkk330
    kkk330
    Aug 17, 2016❤️1
    2
    laravel 直接 return 默认返回的就是 json, 不用手动 response()->json(), 这点很爽
    netcan
    netcan
    OP
    Aug 17, 2016
    3
    @kkk330 这样啊, 3Q 。。。我一直 responce()->json()。。。。有空就改改
    cha1
    cha1
    Aug 17, 2016❤️1
    4
    跟踪了下源码,挺有意思的。

    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
    xiaome
    Aug 21, 2016
    5
    转义一下吧。
    https://ooo.0o0.ooo/2016/08/20/57b92d02d00df.png
    netcan
    netcan
    OP
    Aug 21, 2016
    6
    @xiaome 这个的话,刷新下就没问题了。。。其实是只执行一次的,我去看看 js 怎么转义。。
    netcan
    netcan
    OP
    Aug 21, 2016
    7
    @xiaome 已转义
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1667 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 00:05 · PVG 08:05 · LAX 16:05 · JFK 19:05
    ♥ Do have faith in what you're doing.