javascript - Cordova unable to post data to server using ajax -


i developing phonegap cordova application , want post data server using ajax not able to, getting error.

my example code is:

    <script>         $(document).ready(function()         {          $('#frm').submit(function()     {      var username = $('#textinput').val();     var username = $.trim(username);     var password = $('#passwordinput').val();     var password = $.trim(password);      {          alert('please enter username');         return false;      }     else if(password =='')     {         alert('please enter password');         return false;     }     else     {         var user = $('[name=username]').val();         var pass = $('[name=password]').val();          $.ajax({         type: 'post',         url: 'http://eqfree***p.com/log_sb.php',         rossdomain: true,         beforesend : function() {$.mobile.loading('show')},         complete   : function() {$.mobile.loading('hide')},         data: { username:'user', password:'pass'},           datatype: 'json',         success: function(data){             alert(data.success);             alert('success');          },         error: function(){             alert('error!');          }     });  return false;     } });         });           </script> 

try one

<script> $(document).ready(function() {    $('#frm').submit(function()   {    var username = $('#textinput').val();   var username = $.trim(username);   var password = $('#passwordinput').val();   var password = $.trim(password);    else if(username =='')//check condition   {      alert('please enter username');     return false;    }   else if(password =='')   {     alert('please enter password');     return false;   }   else   {     //no need re initialize     //var user = $('[name=username]').val();     //var pass = $('[name=password]').val();      $.ajax({     type: 'post',     url: 'http://eqfree***p.com/log_sb.php',     crossdomain: true,     beforesend : function() {$.mobile.loading('show')},     complete   : function() {$.mobile.loading('hide')},     data: { 'username':username, 'password':password},       datatype: 'json',     success: function(data){       alert(data.success);       alert('success');      },     error: function(){       alert('error!');        }     });     return false;   }   }); }); </script> 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -