rall0r
(Rall0r)
April 7, 2014, 12:53pm
1
Hi,
I have an webpage containing many small forms created by CActiveFrom widget. Sending form data happens trough ajax in the background, which works fine.
But now, I need to display the return string from the ajax call, after the form was processed successful.
Is there a way to define an own callback-function, which is fired after successfully send the CActiveForm?
Thank you,
rall0r.
rall0r
(Rall0r)
April 8, 2014, 9:10am
2
To answer my own question… maybe someone has the same issue. The solution is quit simple.
This CActiveForm sends data using Ajax, because the submit button is an CHtml::ajaxSubmitButton.
So the secret is not to set an callback function at the form-widget configuration. You have to use the ‘success’ option from the ajaxSubmitButton:
echo CHtml::ajaxSubmitButton('Save', 'http://post.date.url),
array('success'=>'function(data){console.info(data);}'),
array('title'=>'Click to save','class'=>'submitBtn' ));
rall0r:
To answer my own question… maybe someone has the same issue. The solution is quit simple.
This CActiveForm sends data using Ajax, because the submit button is an CHtml::ajaxSubmitButton.
So the secret is not to set an callback function at the form-widget configuration. You have to use the ‘success’ option from the ajaxSubmitButton:
echo CHtml::ajaxSubmitButton('Save', 'http://post.date.url),
array('success'=>'function(data){console.info(data);}'),
array('title'=>'Click to save','class'=>'submitBtn' ));
Try this Code In Your Own jave script function
[color="#2E8B57 "]url ="//Url Path;
$.ajax({url:url,success:function(result){
$("#mainscreen ").html(result);
$("#new_req ").show();
}});[/color]