cms ajax,October CMS - Ajax URL?

可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):

问题:

I want to use Angular JS for October CMS. But how to i POST data to the controllers?

I found this in the October framework.js file

headers: {

'X-OCTOBER-REQUEST-HANDLER': handler,

'X-OCTOBER-REQUEST-PARTIALS': this.extractPartials(options.update)

},

But i have a hard time debugging it.

What is the URL this posts to? And how would i use this.extractPartials(options.update)

回答1:

If you want to post a simple data to the controller and want to update the view file, then you better go with october cms convenient way of handling AJAX through data attributes.

Refer the documents https://octobercms.com/docs/cms/ajax. You can go with java script ajax api only if there is a complex situation like posting a file data and so on..

回答2:

seems you want to fire AJAX using angular.

you just need handler as another part "partial thing" that you can handle by your self as you are firing request.

X-OCTOBER-REQUEST-HANDLER:<<_class_name>>::<<_action>>

<<_action>> -> here you need method which has prefix "on"

onListUpdate something like that.

then October will automatically find that controller and that action and return you json response and you can use that response as you like.

回答3:

I don't know much about JS frameworks however, I think Octobers standard response data is rendered html and scripts/styles to be injected by the framework. Instead you should create your own Routes and return the appropriate response.

E.g:

# Author/Plugin/Plugin.php

public function onBoot() {

Route::get('ajax/endpoint', function() { return Post::all() });

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值