如何在PHPFox中通过Ajax获取任何DOM元素 [英] How to get any DOM Element by Ajax in PHPFox

查看:245
本文介绍了如何在PHPFox中通过Ajax获取任何DOM元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我可以使用

$this->get('element_id')

获取Ajax函数中每个DOM元素的值.但这是行不通的.只有Post-Elements我可以这样,对吗? 但是我如何获得其他元素?

to get the value of each DOM-Element in a Ajax-Function. But that doesn't work. Only Post-Elements i can get this way, right? But how do i get other Elements?

感谢您的帮助...

这是我的Ajax级:

class Name_Component_Ajax_Folder_Ajax extends Phpfox_Ajax
{
public function test(){

    $iChildItemId = $this->get('element_id');
    var_dump($iChildItemId);
    $this->html('#testdiv', $this->getContent());
}
}

通过单击链接,我调用此函数(test()),我想获取输入字段的值(elemnt_id)

By clicking a link i call this function ( test() ) and i want to get the value of an input-field (elemnt_id)

推荐答案

基本上,您有2种常见的解决方案来在Web浏览器(Firefox,Chrome等)发送给服务器的AJAX请求中传递值.

Basically, you have 2 common solutions to pass a value in an AJAX request that Web browse (Firefox, Chrome, ...) sends to server.

如果使用的是POST请求,则应将期望值指定为隐藏输入<input type='hidden' id='val1' value='value_you_want_to_pass_to_sever'>.

If you are using POST request, you should specific your expected value as a hidden input <input type='hidden' id='val1' value='value_you_want_to_pass_to_sever'>.

如果使用的是GET请求,则可以使用URL参数传递该请求,例如:www.youserver.com?val1=value_you_want_to_pass.

If you are using GET request, you can pass it by using URL param for ex: www.youserver.com?val1=value_you_want_to_pass.

您可以使用JQuery获得要传递的价值.

You can get value you want to pass by using JQuery.

然后,您可以使用$ this-> get('val1')在服务器端获取价值.

Then you can use $this->get('val1') to get your value at server side.

这篇关于如何在PHPFox中通过Ajax获取任何DOM元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆