Welcome Guest, Not a member yet? Register   Sign In
How can i call a jquery dialogue box if form submitted successfully ?
#5

[eluser]LuckyFella73[/eluser]
You can use this js and edit like needed:
Code:
// in your header:
<scr + ipt type="text/javascript">
var ci_base_url = '&lt;?php echo base_url();?&gt;';
</scr + ipt>

// put this in a js file and load it
$('#id_submit_button').click(function (e) { // or choose submit event
e.preventDefault();

var form_data = {
  form_field_name: $('#id_form_element').val()
};

$.post(ci_base_url + "controller_name/method_name" , {
  "form_field_name": form_data.form_field_name
},
function(data){
  if (data.validation_flag == 1) {
   // validation passed
   // display success message
  }
  else {
   // validation failed
   // display error message
  }
  
}, "json");
});

In your controller you can use the form_validation library as usual.
Return JSON like
Code:
// ...
die( json_encode($result_array));

and set the array index "validation_flag" according to the validation result.


Messages In This Thread
How can i call a jquery dialogue box if form submitted successfully ? - by El Forum - 07-25-2012, 06:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB