我有一个按键,其中包含data-attributes
个和 MyComp 的组件。
调用Component时,应在:executeMyComp(sfWebRequest $request)
之前运行一个函数。进入我的 executeMyComp 我做了一些Propel SQL,但我需要从Button通过AJAX发送一些变量。
谢谢。
答案 0 :(得分:0)
对于executeMyComp
之前的函数,您可以使用preExecute
函数。它们在实际操作之前运行,您可以通过使用getModuleName和getActionName方法检查它是否是特定操作来编写代码。
关于你的第二个问题,我总是使用JQuery Ajax函数,因为通过使用原型ajax总会有一些冲突。它使用起来非常简单,您可以将请求的值发送给特定的操作。所以不需要将它们添加到会话
$(document).ready( function(){
$.ajax({
type: "POST",
url: "your action URL",
data: fields, // this fields variable(a string full of parameters) will be sent by request and you can get them using getParameter
success: function(data){
//if everything goes well you come here.here you can show your response.
}
});
});
当然没有必要说你可以通过jquery将属性保存到变量中,然后通过ajax发送它们:
var myvar=$("#componentid").val();