繁体   English   中英

如何动态更新Codeigniter视图?

[英]How to update codeigniter view dynamically?

我正在使用第三方API。 当用户使用第三方应用程序并执行某些活动(例如消息传递)时,第三方将向我发送活动的JSON请求到我的CodeIgniter应用程序端点。

我想通过用户发送了一些消息等通知来更新CodeIgniter的视图。

我需要一些如何实现此目标的方法。 谢谢

使用Ajax(Core或JQuery AJAX)。我更喜欢JQuery AJAX

 // You can use a setInterval also, but im using button click to call api $(document).on('click', '.button', function(event) { event.preventDefault(); var url1 = BASE_URL+"controller/method"; // Or your API $.ajax({ url: url1, type: 'GET', dataType: 'json', success : function(response){ // Access the json objects like this // eg. response.status, response.data etc. // Do DOM manipulation // eg. $('#target').text(response.data) }, failure : function(response){ alert("Error! Please Contact technical support"); } }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM