php - Server side varification after client side done -
suppose have login form 2 form elements i.e username , password. in client side verification not set required option in username. target after make client side verification want varify server side through ajax, username field verified in server side,if username blank php check , response json. want parse data , show validation error , show if login authentication error message different div element in login form. not this. please me issue.
$(document).ready(function(){ // initialize validator , add custom form submission logic $("#loginform").validator().submit(function(e) { var form = $(this); // client-side validation passed if (!e.isdefaultprevented()) { $.ajax({ type: "post", url: "process.login.php", data: $('#loginform').serialize(), datatype: "json", success: function(msg){ if(parseint(msg.status)==1) { window.location=msg.txt; } } }); // prevent default form submission logic e.preventdefault(); } }); });
i guess want know how php (server) validation response work?
<?php // validation here ... $msg = array("status"=>1, "text"=>"some text here"); echo json_encode($msg);
Comments
Post a Comment