JSON學習

學習資料
- 入門資料
1, 深入淺出JSON ( http://www.cnblogs.com/Truly/archive/2006/12/31/608896.html )
2, JavaScript中的JSON ( http://www.dreamdu.com/blog/2008/10/19/json_in_javascript/ )

使用
1,GetWF.ashx文件
<%@ WebHandler Language="VB" class="GetWF" %>

Imports System
Imports System.Web

Public Class GetWF : Implements IHttpHandler

    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        context.Response.ContentType = "text/plain"
        Dim _wf As String = "[[{WN:'a'},{WV:'aV'}],[{WN:'b'},{WV:'bV'}]]"
        Dim _reqNo As String = context.Request.QueryString("CheckRequestNo")
        Dim _wfpersent As String = Global.WorkFlow.GetPresentWFIdByReqId(_reqNo)
        '------------------------------------------------------------------
        Dim db As New DBUtility.DatabaseHelper
        Dim sb As New Text.StringBuilder
        Dim ds As New Data.DataSet

        sb.Append(" select distinct rw.WF_id,rw.WF_CODE from workflow rw  ")
        sb.Append(" where rw.WF_ID<'130' ")
        sb.Append(" and rw.wf_id>='" & _wfpersent & "' ")

        ds = db.ExecuteDataSet(sb.ToString())
        _wf = "["
        _wf += "[{WN:''},{WV:''}],"
        For Each dr As Data.DataRow In ds.Tables(0).Rows
            _wf += "[{WN:'" & dr("WF_id").ToString() & "'},{WV:'" & dr("WF_CODE").ToString() & "'}]" + ","
        Next
        _wf = Global.StringUtility.DelLastComma(_wf)
        _wf += "]"

        '------------------------------------------------------------------
        context.Response.Write(_wf)
    End Sub

    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

2,ASPX
 <asp:DropDownList ID="ddlWorkFlow" runat="server" AutoPostBack="True" CausesValidation="True">
 </asp:DropDownList>

3,JS
 function setDropListWF()
 {
    $.ajax({
    type: "GET",
    url: "CheckRequestNo.ashx",
    data: "CheckRequestNo="+$("#txtSourceReqeustNo").val(),
    success: function(result){
  if(result==0)
  {
      alert("申請單號不存在");
      return false;
  }
  else
  {
      $.ajax({
         type: "GET",
         url: "GetWF.ashx",
         data: "CheckRequestNo="+$("#txtSourceReqeustNo").val(),
         success: function(result){
          //alert(result);
          eval("wf="+result);
          //alert(wf[0][0].WN+wf[0][1].WV);
         
          var ddlWF=document.getElementById("ddlWorkFlow")
          //ddlWF.options.add();                              
         var l=ddlWF.options.length
    for(var i=0;i<l;i++)
    {
    ddlWF.remove(0);
    }
    for(var i=0;i<wf.length;i++)
    {
        ddlWF.add(new Option(wf[i][1].WV,wf[i][0].WN));
        //alert(wf[i][0].WN);
    }
    form1.submit();
       }
         });
  }
    }
 });
 }

 

转载于:https://www.cnblogs.com/htht66/archive/2010/11/16/1878711.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值