How to do AJAX in jQuery with JSON callback in Zend Framework
Filed Under (General) by Wenbert on 20-03-2008
Tagged Under : AJAX, JSON, Zend Framework
Here is how to do it in Zend Framework.
Let’s start with the form:
-
-
<textarea id="mytext">
-
</textarea>
-
<input type="button" id="mybutton" value="go" />
-
-
< script language="Javascript">
-
//jQuery stuff
-
$(document).ready(function() {
-
$("#mybutton").click(function() {
-
$.post("< ?=$this->baseUrl?>/path/to/my/coolaction",{
-
mytext: $(‘#mytext’).val()
-
}, function(data){
-
//alert("Data Loaded: " + data);
-
obj = window.eval(data);
-
alert("Saved: "+obj[‘mytext’]);
-
},"json");
-
});
-
});
-
< / script>
-
In your controller-action: