Jquery validation in login form asp.net c# with webservice -


hello have created login form in asp.net redirect page have created webservice user validation , jquery ajax data returning undefined page not redirecting please me ... code this

webservice

 [webmethod]     public static string loginser(string un,string pwd)     {          using (sqlconnection con = new sqlconnection(constr))         {             using (sqlcommand cmd = new sqlcommand("select username,password emp_login isactive=1 , username='" + un + "' , password='" + pwd + "'", con))             {                 con.open();                 cmd.executenonquery();                 con.close();                 sqldataadapter da = new sqldataadapter(cmd);                 datatable dt = new datatable();                 da.fill(dt);                 if (dt.rows.count > 0)                 {                     return "1";                 }                 else                 {                     return "0";                 }             }         }      } 

jquery

$(document).ready(function () { $("#btnlogin").click(function () {     var uid = $("#txtun").attr('value');     var pass = $("#txtpwd").attr('value');     $.ajax({         type: "post",         url: "login.aspx/loginser",         data: '{un: ' + uid + ', pwd: ' + pass + '}',         contenttype: "application/json; charset=utf-8",         datatype: "json",         success: function (data) {             if (data.d == "1")             {                 window.location.assign("../../home.aspx");             }         },         error: function (xmlhttprequest, textstatus, errorthrown) {             //alert(xmlhttprequest.responsetext);             var err = eval("(" + xmlhttprequest.responsetext + ")");             alert(err.message);         }      });  }); }); 

i think url in ajax call incorrect. need provide service name, such login.asmx, , not page (i.e. login.aspx).

i not sure way passing data, may correct though.

.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -