这是Md.XaYed Asfee,我是asp vb.net的新手我面临一个问题,我不知道为什么,请帮助我... 2013年视觉工作室
这是我的javascript代码
$("#name").blur(function () {
//e.preventDefault();
var aData = $("#name").val();
//alert(aData);
$.ajax({
type: "GET",
//url: "/files/rettxtvalpros.aspx/EmployeeDetails?country_nm='" + aData + "'",
url: "/master.aspx/EmployeeDetails",
//data: '{country_nm: "' + aData + '" }',
data: '{ country_nm:'+ aData +'}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (a) {
var dat = JSON.parse(a.d);
//var so = dat[1];
alert(dat);
//var dat = JSON.parse(a.d);
//var dat = data.d;
//var iso = dat[0];
//$("#iso").val(iso);
//$("#pname").val() = dat.pname;
//$("#iso3").val() = dat.iso3;
//$("#ncode").val() = dat.ncode;
if (a.d != '')
{
alert("0");
//alert(a[0]);
}
//if (conf == '')
//{
// alert("Null");
//}
},
failure: function (data) {
//var r = jQuery.parseJSON(response.responseText);
//alert("Message: " + r.Message);
//alert("StackTrace: " + r.StackTrace);
//alert("ExceptionType: " + r.ExceptionType);
alert("1");
}
});
});
});
,这是我的vb代码
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Web.Script.Services
Imports System.Web
Imports System.Data.SqlClient
Imports System.Linq
Imports System.Xml
Imports System.Web.Script.Serialization
Public Class master
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Class country
Public iso As String
Public name As String
Public printable_name As String
Public iso3 As String
Public ncode As String
End Class
Private _name As String
Public Property country_nm As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Function EmployeeDetails(country_nm As String) As List(Of String)
Dim objEmployee As New country ' CREATE AN OBJECT.
Dim a As New List(Of String)()
'MsgBox(country_nm)
Dim conn As String = ConfigurationManager.ConnectionStrings("sQlConn").ConnectionString
Dim myConn As New SqlConnection(conn)
Dim objComm As New SqlCommand("SELECT * FROM country_iso WHERE printable_name LIKE '%' + @LookUP + '%' ", myConn)
'Dim objComm As New SqlCommand("SELECT * FROM country_iso", myConn)
myConn.Open()
objComm.Parameters.AddWithValue("@LookUP", country_nm)
Dim sdr As SqlDataReader = objComm.ExecuteReader()
'If sdr.Read Then
'objEmployee.name = sdr("name").ToString()
'objEmployee.iso3 = sdr("iso3").ToString()
'objEmployee.ncode = sdr("numcode").ToString()
'objEmployee.iso = sdr("iso").ToString()
'objEmployee.printable_name = sdr("printable_name").ToString()
'End If
If sdr.Read Then
a.Add(sdr("iso").ToString())
a.Add(sdr("name").ToString())
a.Add(sdr("printable_name").ToString())
a.Add(sdr("iso3").ToString())
a.Add(sdr("numcode").ToString())
End If
MsgBox(sdr("name").ToString())
Dim serializer As JavaScriptSerializer
myConn.Close() : sdr.Close() : Return a
End Function
End Class
我应用了很多教程但没有找到任何结果......