Javascript调用Webservice的多种方法
通过xmlhttp+webservice(原始方法)
原文地址:http://netboy.cnblogs.com/archive/2006/02/18/333260.html
view plaincopy to clipboardprint?
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[webservice(namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service ()
{
//uncomment the following line if using designed components
//InitializeComponent();
}
[webmethod]
public string SayHelloTo(string Name)
{
return "Hello "+Name;
}
}
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[webservice(namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service ()
{
//uncomment the following line if using designed components
//InitializeComponent();
}
[webmethod]
public string SayHelloTo(string Name)
{
return "Hello "+Name;
}
}
还是俗了点。:)
2. js调用webservice+xmlhttp的实现部分。
view plaincopy to clipboardprint?
<html>
<title>Call webservice with javascript and xmlhttp.</title>
<body>
<mce:script language="javascript"&
相关文档:
<mce:script language="javascript" ><!--
function person(name,age)
{
this.name=name;
this.age=age;
}
function man(name,age)
{
this.sex="男";
this.base=person;
this.base(name,age);
}
function woman(name,age)
{
this.sex="女";
this.base=person;
this.base(name,age)
}
......
javascript中setTimeout()函数
大家都知道javascript中的setTimeput()函数的作用,一般会用他来处理一些连续的事情,们先看一个例子:
<head>
<script>
function init()
  ......
JavaScript不区分单个字符和字符串,任何字符或字符串可以用双引号或单引号引起来。如果字符串本身含有双引号,则应使用单引号将字符串括起来;如果字符串本身含有单引号,则应使用双引号将字符串引起来,两者可以嵌套使用。 ......
有时候进行ajax交互的时候,返回的数据可以自己添加分隔符,比如^^^,然后对这些分隔符进行解析,分解为一个数组。
function fill(v) {
if (v == undefined)return false;
var result = v.split("^^^");
$("#cnPatent").val(result[0]);
$("#cnPText").val(result[1]); ......
1.asp.net呼叫js
Response.Write("<script language=javascript>");
&n ......