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"&
相关文档:
一、主页面(采用jsp实现)
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@page import="org.accp.jwebplayer.biz.MusicBiz"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<h ......
这个效果应该不算什么稀奇,网上也有现成的代码,我这个也没什么特别的地方,只是因为我自己写的,也算是为学习DOM后一个练习;在IE下测试通过;
实现效果是这样的:
读取XML文档;
采用递归生成无限级的树形菜单;
能够响应鼠标事件,展开与拆叠子级菜单;
首先是生成一个XML文档,我用的是XML Spy的编辑器;
< ......
JavaScript中的模块和名字空间是不可区分的内容。
我们定义的每个单独的函数都是作为全局对象的一个属性。而JavaScript代码模块所必须遵循的最重要的规则就是:避免定义全局变量。因为,当定义一个全局变量时,都要被其他模块覆盖的危险,所以模块化编码要用如下方式:
var ModuleClass={};
ModuleClass.函数名1=functio ......
常用:javascript字符串函数 收藏
concat
将两个或多个字符的文本组合起来,返回一个新的字符串。
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
返回字符串中一个子串第一处出现的索引(从左到右搜索)。如果没有匹配项,返回 -1 。
var index1 = a.indexOf ......
完全打开页面后,在该页的在IE地址栏 或 按Ctrl+O 输入以下代码,回车,就可以得到相应的效果:
1.显示网页中的所有图片
javascript:Ai7Mg6P='';for%20(i7M1bQz=0;i7M1bQz<document.images.length;i7M1bQz++){Ai7Mg6P+='<img%20src='+document.images[i7M1bQz].src+'><br>'};if(Ai7Mg6P!=''){document.wri ......