简体   繁体   English

如何在不刷新cakephp中的浏览器的情况下从其他浏览器获取数据?

[英]how can i get data from other browser without refreshing browser in cakephp?

i am new to cakephp, and also new to ajax. 我是Cakephp的新手,也是ajax的新手。

the function i trying to do is basically like this: i am in a add page, which let me select few customer on that page. 我尝试执行的功能基本上是这样的:我在添加页面中,这使我可以在该页面上选择几个客户。 but i wanted to set 1 more link for user, which let user click customer immediately on the add page, and the new data will show in my add page without refresh, so that the user can choose the new added customer for enter my form. 但我想为用户设置1个链接,让用户立即在添加页面上单击客户,新数据将显示在我的添加页面中,而无需刷新,以便用户可以选择新添加的客户来输入我的表单。

i know the idea is base on using ajax. 我知道这个想法是基于使用Ajax。 but i am still new to it and hope any 1 can give some comment or suggestion how can i start?? 但我仍然很陌生,希望任何人都可以提出一些意见或建议,我应该如何开始?

the problem i face is, i am on a form, when i adding a new customer in the form, i wanted to get the new customer to show in my form without refresh. 我面临的问题是,我在表单上,​​当我在表单中添加新客户时,我想让新客户在表单中显示而不刷新。 what can i do for getting this function? 我该怎么做才能获得此功能?

thanks a lot and i will very appreciate your answer. 非常感谢,我将非常感谢您的回答。

CakePHP has an ajax helper, which requires the prototype library. CakePHP有一个ajax帮助器,它需要原型库。 You can find the API for the AJAX helper here: 您可以在这里找到AJAX帮助程序的API:

http://api.cakephp.org/class/ajax-helper http://api.cakephp.org/class/ajax-helper

And a guide to using the helper here: 以及在此处使用帮助器的指南:

http://book.cakephp.org/view/208/AJAX http://book.cakephp.org/view/208/AJAX

And a list of cakephp/ajax articles here: 以及这里的cakephp / ajax文章列表:

http://bakery.cakephp.org/articles/search/tags/ajax http://bakery.cakephp.org/articles/search/tags/ajax

It's beyond the scope of a Stack Overflow answer to give you a tutorial but hopefully these links will help. 为您提供教程超出了Stack Overflow答案的范围,但希望这些链接会有所帮助。

easiest way is to use a javascript library (like jquery for instance) to do an ajax request. 最简单的方法是使用javascript库(例如jquery)执行ajax请求。 probably to a controller/action in your cake framework. 可能是蛋糕框架中的控制器/动作。

the easiest way would probably be returning the data in JSON and filling out your form fields. 最简单的方法可能是返回JSON中的数据并填写表单字段。

PHP Json PHP的杰森
jQuery AjAX/JSON jQuery AjAX / JSON

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

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