sharepoint中javascript调用webservices的ajax步骤

 

1.创建适用于sharepoint的webservices,步骤MSDN上有,参见:http://msdn.microsoft.com/en-us/library/ms464040.aspx

2.配置ajax环境,

Modify web.config file to include AJAX support, Refer to the “<!--for ajax (x of 7), start-->” tags in the sample web.config. There are 7 places need to be added. 

 

 

Web.Config

 

 3.Webpart中的ajax注册

 

AjaxManager

 

4.js调用

 

function slechang(){
    var sletype = $("SelectSchoolType");
    var sleschool = $("SelectSchool");
    initCallBackSelect(sleschool);
    if (sletype.selectedIndex != 0) {
        var ws = new ConceptInc.SchoolBundle.SchoolListingWebService.SchoolListingWebService();
        ws.arraydata(sletype.options[sletype.selectedIndex].value, xmlpath, onSucceeded, onFailed);
    }
    else {
        initSelect(sleschool);
    }
}

function onSucceeded(result){
    var sleschool = $("SelectSchool");
    var arraystr = result.toString().split(",");
    //alert(result);
    initSelect(sleschool);
    for (var i = 0; i < arraystr.length / 2; i++) {
        if (arraystr[0] != 0) {
            var opt = new Option();
            opt.text = arraystr[i].toString();
            opt.value = arraystr[arraystr.length / 2 + i].toString();
            sleschool.options.add(opt);
        }
        else {
            initSelect(sleschool);
        }
    }
}

function onFailed(error){
    alert(error);
}

 

posted @ 2009-04-02 10:37  geek007  阅读(428)  评论(1编辑  收藏  举报