cordova - How to make run a javascript function that calls a web service from another project -


in phonegap project need call web service login stuff. can run web service , make visible; when try call login button's on-click; doesn't return errors nor anything. help.

that userlogin.js

function login() { $("#loginbuton").click(function() {                     var requestdata = {                         email : $('#email').val(),                         password : $('#password').val()                     };                      $.ajax({                                 type : 'post',                                 datatype : 'json',                                 headers: { 'access-control-allow-origin': '*' },                                 origin: 'http://localhost:8080',                                 contenttype : 'application/json; charset=utf-8',                                 url : 'http://localhost:8080/mywebserviceprojectname/ws/userlogin/userlogincontrol',                                 data : json.stringify(requestdata),                                 crossdomain: true,                                 success : function(responsedata) {                                     onsuccess(responsedata);                                 }                             });                 }); 

}

this login.html

<html> <body> <head> <script src="js/jqm.globals.js"></script> <script src="jsandroid/jquery.min.js"></script> <script src="jsandroid/userlogin.js"></script> <script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script> </head> <body> <div data-role="page">      <div data-role="header" style="background: #31b404; color: white;">         <h1>welcome</h1>     </div>      <div data-role="content">         <div id="ortala">             <div class="span-2 fl">                 <!--login-->                 <div class="controls-login">                     <div class="form-login">                         <h3>giris</h3>                         <form>                             <div class="form-item">                                 <input type="text" id="email" placeholder="kullanici adi" />                             </div>                             <div class="form-item">                                 <input type="password" id="password" />                             </div>                              <div class="form-item">                                 <a href="yeniuyeekleme.html" rel="external">uye degil                                     misiniz?</a>                             </div>                             <div class="form-item">                                 <input type="button" id="loginbuton" value="giriş yap"                                     onclick="login();"                                     style="background-color: ffffff; color: #090101;" />                             </div>                         </form>                     </div>                 </div>             </div>         </div>     </div> </div> 

you calling function setup event listener.

remove onclick="login();" input button , replace login() following:

$(function() {     $("#loginbuton").click(function() {         var requestdata = {             email : $('#email').val(),             password : $('#password').val()         };          var request = $.ajax({             type : 'post',             datatype : 'json',             contenttype : 'application/json; charset=utf-8',             url : 'http://localhost:8080/mywebserviceprojectname/ws/userlogin/userlogincontrol',             data : json.stringify(requestdata),             crossdomain: true         });          request.done(function(data) {             console.log(data);             onsuccess(responsedata);         });          request.fail(function(jqxhr, textstatus) {             console.log("request error: " + textstatus);         });     }); }); 

make sure remove console.log() frpm both done & fail events if using ie, or when done testing break browsers.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -