朋友
我如何把Ajax与冻结框架结合起来。 我需要一些良好的辅导。
朋友
我如何把Ajax与冻结框架结合起来。 我需要一些良好的辅导。
把这个放到你的控制器中。
public function init()
{
$contextSwitch = $this->_helper->getHelper( contextSwitch );
$contextSwitch->addActionContext( test , json )
->initContext();
}
创建一个测试动作 (Créer un test d'action)
public function testAction()
{
$this->view->var1 = "I m testing";
}
然后在您的视图中使用 jQuery 进行请求。
<script type="text/javascript">
$(document).ready(function(){
$( #display ).ajaxStart(function(){
$(this).html( Loading... );
});
str = $( #test ).val();
$( #link ).bind( click ,function(event){
event.preventDefault();
$.post(
this.href,
{ var1: str, format: json },
function(data){
$( #display ).html(data.var1);
},
"json"
);
});
});
</script>
<input type="text" name="test" id="test" value="just testing" />
<p>
<a href="<?php echo $this->url(array( controller => index , action => test )); ?>" id="link">Testar</a>
</p>
<div id="display">...</div>
你可以在你的控制器中使用类似这样的东西:
public function testAction() {
// Remove all of your HTML stuff
$this->_helper->layout->disableLayout();
// PHP to create an array form database or something
// This will return the info as json. It takes care of the header and everything else!
return $this->_helper->json->sendJson( array( test ) );
}
I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...
I m trying to find a reusable way to set focus from one text box to another upon enter using ASP.NET, but using client-side JavaScript to do so. The only reason I mention this is to be done in ASP....
I have some Javascript JQuery code that does an Ajax call to the server every 5 mins, it s to keep the server session alive and keep the user logged in. I m using $.ajax() method in JQuery. This ...
Why are my AJAX requests failing? I have a website www.foo.com, and I m running Tomcat on the same server, www.foo.com:8080/services. However, when a file on foo.com makes an ajax call as such: $....
I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...
I have a entry form. Below it, I want to show a grid containing existing records. As the user clicks on a row of the grid, the values must get filled in the fields of the form above. Is there any way ...
I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...
Ok, I m stumped. Basically, this script works fine in FF, but not in IE (6,7 or 8) - in which it returns an "Object doesn t support this property or method" error. Any ideas?: function ...