我现在是这样写的 function GetMenuNavigation() { var MenuNavigationID = "1"; var proxy = new Navigation.INavigation(); proxy.GetLeftMenuNavigationList(MenuNavigationID, Succeeded); } function Succeeded(Result) { //处理结果集合 } 我想这样写,直接接受到返回值, function GetMenuNavigation() { var MenuNavigationID = "1"; var proxy = new Navigation.INavigation(); var Result = proxy.GetLeftMenuNavigationList(MenuNavigationID); //我想直接处理结果集合,让这个方法返回值后再继续往下执行。 }
270281544*qq.com
function GetMenuNavigation() {
var MenuNavigationID = "1"; var proxy = new Navigation.INavigation();
proxy.GetLeftMenuNavigationList(MenuNavigationID, Succeeded);
} function Succeeded(Result) { //处理结果集合 }
我想这样写,直接接受到返回值,
function GetMenuNavigation() {
var MenuNavigationID = "1"; var proxy = new Navigation.INavigation();
var Result = proxy.GetLeftMenuNavigationList(MenuNavigationID);
//我想直接处理结果集合,让这个方法返回值后再继续往下执行。
}
配置文件<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WebBehavior">
<!--httpGetEnabled - 指示是否发布服务元数据以便使用 HTTP/GET 请求进行检索,如果发布 WSDL,则为 true,否则为 false,默认值为 false-->
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="NavigationBehavior">
<!--enableWebScript - 启用 WCF 服务的 脚本 编程模型-->
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<!--name - 提供服务的类名-->
<!--behaviorConfiguration - 指定相关的服务行为配置-->
<service name="RTERP.Services.SYSManage.NavigationService" behaviorConfiguration="WebBehavior" >
<!--address - 服务地址-->
<!--binding - 通信方式-->
<!--contract - 服务契约-->
<!--behaviorConfiguration - 指定相关的端点行为配置-->
<endpoint address="" binding="webHttpBinding" contract="RTERP.Contract.SYSManage.INavigation" behaviorConfiguration="NavigationBehavior" />
</service>
</services>
</system.serviceModel>
</configuration>服务文件里面的内容
<%@ ServiceHost Language="C#" Debug="true" Service="RTERP.Services.SYSManage.NavigationService" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>服务接口using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RTERP.Domain.SYSManage;
using System.ServiceModel;
using System.ServiceModel.Web;
using RTERP.Domain;namespace RTERP.Contract.SYSManage
{
[ServiceContract(Namespace = "Navigation")]
public interface INavigation
{
/// <summary>
///
/// </summary>
/// <param name="FatherNavigationID"></param>
/// <returns></returns>
[OperationContract]
IList<Navigation> GetNavigationList(string FatherNavigationID); /// <summary>
///
/// </summary>
/// <param name="FatherNavigationID"></param>
/// <returns></returns>
[OperationContract]
string GetLeftMenuNavigationList(string FatherNavigationID); }
}
服务using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RTERP.Domain.SYSManage;
using RTERP.Persistence.SYSManage;
using RTERP.Contract.SYSManage;
using RTERP.Domain;namespace RTERP.Services.SYSManage
{
public class NavigationService : INavigation
{
NavigationDao _NavigationDao = new NavigationDao();
public IList<Navigation> GetNavigationList(string FatherNavigationID)
{
return _NavigationDao.GetNavigationList(FatherNavigationID);
} public string GetLeftMenuNavigationList(string FatherNavigationID)
{
StringBuilder sb = new StringBuilder(); //访问数据库
//拼接导航字符串
return sb.ToString(); }
}
}