2

我是 android phonegap 应用程序的新手。我试图通过 android 模拟器应用程序中的 rest api 进行登录,但总是以 jquery ajax 错误函数结束,我使用了 IP 地址 10.0.2.2 但仍然无法正常工作 - 我怎样才能获得 jquery ajax 的成功响应来自安卓模拟器。这里我给出js代码..

$.ajax({
          url: 'http://10.0.2.2/wedding/Source/Website/api/login',
          type: 'POST',
          data: $('#loginPageForm').serialize(),
          success: function(data){
             /*Process your response here*/
              alert(data);
          },
          error: function(jqXHR, textStatus, errorThrown){
            alert(99999);
          }
       });


                   And here is the html form I am using for login ...

<form method="post" data-ajax="false" id="loginPageForm">
         <fieldset>
             <div data-role="fieldcontain">
                 <label for="basic">Username:</label>
                 <input type="text" name="User[username]" id="loginPageUsername" value=""  />
             </div>
             <div data-role="fieldcontain">
                 <label for="basic">Password:</label>
                 <input type="password" name="User[password]" id="loginPagePassword" value=""  />
             </div>
             <div data-role="fieldcontain">
                 <button value="Login" name="loginPageSubmit" type="button" onClick="doLogin()">Login</button>
             </div>
         </fieldset>
     </form>

我已经通过正常工作的休息客户端测试了休息应用程序,然后我还在也在运行的浏览器上测试了该应用程序,但相同的代码在 Android 模拟器上不起作用。谁能解释一下错误在哪里以及什么我需要做些什么来修复它。

提前致谢..

4

0 回答 0