I have a strange problem, I am performing a simple application process with jquery $ post json, however, nothing is returned, see below how did the codes.:
application.js:
(function($){
$(document).on('submit', "form", function() {
var a = $(this);
if(jQuery().validate) {
$('#'+a.attr('id')).validate({
success: 'valid', submitHandler: function() {
$.post(a.attr('action'), $('#'+a.attr('id')).serialize(), function(r) {
if(jQuery.ui) {
$('#msn').attr('title',r.resp);
$('#msn').html(r.msn);
$("#msn").dialog({
width: 350,
height: 135,
modal: true
});
$("#msn").dialog("open");
} else {
alert(r.msn);
}
}, 'json');
}
});
} else {
console.log('ok');
}
return false;
});
$('form').submit();
})(jQuery);
controller.php
echo json_encode(array(
'resp' => 'ok',
'msn' => 'registered successfully'
));
console.logstatement afterif(jQuery().validate) {and see if it works - anurupr