dojo - dijit/form/form issues POST issues in firefox -


i trying post form using dojo.xhrpost. below code works fine in chrome not work @ in firefox. when doesn't work see page reloads again , nothing happens. tried use dojo.stopevent(event); doesn't seem work in firefox.

can please suggest me mistake. feel issue more form xhrpost.

html looks below:

<div data-dojo-type="dijit/form/form" data-dojo-id="myform" id="loginform"  enctype="multipart/form-data" action="" method="post"> <script type="dojo/method" data-dojo-event="onsubmit">     if(this.validate()){         senddata();  //calling javascript function     }else{         alert('form contains invalid data.  please correct first');         return false;     }     return true;  </script>   <table cellspacing="10">   <tr>   <td><label for="name">username:</label></td>   <td><input type="text" id="username" name="username"    required="true" placeholder="your username" data-dojo-   type="dijit.form.validationtextbox"/></td>   </tr>   <tr>   <td><label for="password">password:</label></td>   <td><input type="password" id="password" name="password"          required="true" placeholder="your password"    data-dojotype="dijit.form.validationtextbox"/></td>   </tr>  </table>  <div id="response" style="float: right"></div>  <button data-dojo-type="dijit.form.button" type="submit" name="submitbutton"      value="submit" style="float: right;">submit</button>  </div> 

my javascript code below:

function senddata(){ dojo.stopevent(event);  obj = {}; obj.user_name =dijit.byid("username").get("value"); obj.password =dijit.byid("password").get("value");  var xhrargs = {           url: "./script/php/validatelogin.php",           postdata: obj,           handleas: "json",           load: function(data){               //alert('success');               if(data.success==true){                   window.location = data.message;                   dojo.byid("response").innerhtml = "form posted.";                 }else{                   dojo.byid("response").innerhtml = "login failed";               }            },           error: function(error){              console.log("error occured!!!");              dojo.byid("response").innerhtml = "failed post form..";                 }           };   //alert('starting');  var deferred = dojo.xhrpost(xhrargs);  //alert('done');   return false;  } 

first, change data-dojo-type path format. e.g.: dijit/form/validationtextbox

second, fix typing mistake in password field of data-dojo-type. entered data-dojotype, missing - b=in between 'dojo' & 'type'

more information dojo.byid() & dijit.byid().

here result:

    <div data-dojo-type="dijit/form/form" data-dojo-id="myform" id="loginform" enctype="multipart/form-data" action="" method="post">     <script type="dojo/method" data-dojo-event="onsubmit">         if(this.validate()){             senddata();  //calling javascript function         }else{             alert('form contains invalid data.  please correct first');             return false;         }         return true;     </script>      <table cellspacing="10">         <tr>             <td><label for="name">username:</label></td>             <td><input type="text" id="username" name="username" required="true" placeholder="your username" data-dojo-type="dijit/form/validationtextbox" /></td>         </tr>         <tr>             <td><label for="password">password:</label></td>             <td><input type="password" id="password" name="password" required="true" placeholder="your password" data-dojo-type="dijit/form/validationtextbox" /></td>         </tr>     </table>     <div id="response" style="float: right"></div>     <button data-dojo-type="dijit/form/button" type="submit" name="submitbutton" value="submit" style="float: right;">submit</button> </div>  <script> function senddata(){     dojo.stopevent(event);      obj = {};     obj.user_name =dijit.byid("username").get("value");     obj.password =dijit.byid("password").get("value");      var xhrargs = {         url: "./script/php/validatelogin.php",         postdata: obj,         handleas: "json",         load: function(data){             //alert('success');             if(data.success==true){                 window.location = data.message;                 dojo.byid("response").innerhtml = "form posted.";               }else{                 dojo.byid("response").innerhtml = "login failed";             }         },         error: function(error){             console.log("error occured!!!");             dojo.byid("response").innerhtml = "failed post form..";         }     };     //alert('starting');     var deferred = dojo.xhrpost(xhrargs);     //alert('done');     return false; } </script> 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -