2013-03-16 44 views
0

我一直试图让这工作很长的时间,但我似乎无法让我的头脑围绕它。jquery webservice登录

我想使用jquery mobile来登录,调用一个ASP.net web服务。 Web服务正常工作,可以使用。 在使用调试器的网页它的结果是这样的:(

This XML file does not appear to have any style information associated with it. The document tree is shown below. 
<boolean xmlns="http://tempuri.org/">true</boolean> 

我不相信有什么毛病我的服务,所以这里是我的网页代码:

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title></title> 

    <script src="res/js/jquery.min.js" type="text/javascript"></script> 
    <script src="res/js/mobile/jquery.mobile-1.3.0.min.js" type="text/javascript"></script> 
    <link href="res/js/mobile/jquery.mobile-1.3.0.min.css" rel="stylesheet" type="text/css" /> 

    <script type="text/javascript"> 

     $(document).ready(function() { 
      $("#submit").click(function() { 

       $.ajax({ 
         type: "POST", 
         url: "http://localhost/as400/services.asmx/Login", 
         data: "{ user: " + $('#usr').val() + ", password: " + $('#psw').val() + "}", 
         contentType: "application/json; charset=utf-8", 
         dataType: "json", 
         success: function (msg) { 
          alert(msg.d); 
         }, 
         error: function() { 
          alert("error!"); 
         } 
        }); 

      }); 
     }); 

    </script> 

    <style> 
     .ui-page { background: White;} 
    </style> 

</head> 
<body> 

<div data-role="page" id="login"> 

<div data-role="header" data-position="fixed"><h1>Login</h1></div> 

<div data-role="content"> 

    <img src="res/img/logo.gif" style="display: block;margin: 1em auto 0;width: 75%;" /> 

    <form id="login_form" name="login_form" data-ajax="false"> 
      <input type="text" name="usr" id="usr" value="" placeholder="user"/> 
      <input type="password" name="psw" id="psw" value="" placeholder="password"/> 
      <input type="submit" value="Login" id="submit" name="login"/> 
      <label><input type="checkbox" name="remember_me" id="remember_me" value="checked_remember"/>Remember me!</label> 
     </form> 

</div> 

<div data-role="footer" data-position="fixed"><h2>Footer</h2></div> 

</div> 

</body> 
</html> 

Webservice代码:

Imports connection 

Imports System.Data 

Imports System.Web 
Imports System.Web.Script 
Imports System.Web.Services 
Imports System.Web.Services.Protocols 
Imports System.Web.Script.Services 
Imports System.Collections.Generic 
Imports System.Web.Script.Serialization 

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
<System.Web.Script.Services.ScriptService()> _ 
<WebService(Namespace:="http://tempuri.org/")> _ 
<WebServiceBinding(Name:="services", ConformsTo:=WsiProfiles.BasicProfile1_1)> _ 
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ 
Public Class services 
    Inherits System.Web.Services.WebService 

    Public connection As New connection 

    <WebMethod()> _ 
    <SoapDocumentMethod(Binding:="services")> _ 
    <SoapHeader("connection")> _ 
    Public Function Execute(sql As String, type As Operation) As Result 

     Dim r As New Result 

     Select Case type 
      Case Operation.SelectMultipleRows 

       Try 
        r.Data = connection.Execute(sql, type) 
       Catch ex As Exception 
        r.ErrorMessage = ex.Message 
        r.SQL = sql 
       End Try 

     End Select 

     Return r 

    End Function 

    <WebMethod()> _ 
    <SoapDocumentMethod(Binding:="services")> _ 
    <SoapHeader("connection")> _ 
    Public Function Login(user As String, password As String) As Boolean 

     Return connection.Login(user, password) 

    End Function 
End Class 

我得到一个警告“错误”,但我不知道为什么... 我已经把web服务放在调试中,它运行良好,但它似乎 像jQuery文章正在处理服务之前出现错误。 。?

也许我在这里做错了什么?

请帮帮我!

THX

斯坦尼

+0

我们可以看到网络服务吗? – writeToBhuwan 2013-03-16 17:23:29

+0

你能告诉我们你使用的是什么版本的jquery吗? – 2013-03-16 17:24:30

+0

包括webservice代码 – grmbl 2013-03-16 17:27:14

回答

0

我是自己通过重新设计来解决这个问题。问题已过时。