Ajax call from a form loaded through ajax (chaining)
Hello,
I was expecting the below scenario common, but couldn't find much help online. I have a form loaded through Ajax (say, create entity form). It is loaded through a button click (load) event
- $("#bt-create").click(function(){
- $ ('#pid').load('/controller/vehicleModel/create3');
- return false;
- });
the response (a form) is written in to the pid element. The name and id of the form is ajax-form, and the submit event is attached to an ajax post request
- $(function() {
- $("#ajax-form").submit(function(){
- // do something...
- var url = "/app/controller/save"
- $.post(url, $(this).serialize(), function(data) {
- alert( data ) ; /// alert data from server
- });
I could make the above ajax operations individually. That is the ajax post operation succeeds if it calls from a static html file. But if I chain the requests (after completing the first), so that it calls from the output form generated by the first request, nothing happens. I could see the post method is called through firebug.
Is there a better way to handle above flow?
thanks.