Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript可以接受长度为27601的字符串吗?_Javascript_Vb.net_Webmethod - Fatal编程技术网

javascript可以接受长度为27601的字符串吗?

javascript可以接受长度为27601的字符串吗?,javascript,vb.net,webmethod,Javascript,Vb.net,Webmethod,我有一个webmethod,它将返回一个带有字符串的对象(即str是object,str(0)是string)。str(0)的长度为27601。同样,具有相同长度的所有其他数组成员。(即)str(1)的长度为27601,str(2)、str(3) 我的webmethod返回确切的对象。但是在客户端,javascript不接受值,它会立即触发错误方法 示例代码是 PageMethods.paging("","",pospara,"position_select","stored Procedure

我有一个webmethod,它将返回一个带有字符串的对象(即str是object,str(0)是string)。str(0)的长度为27601。同样,具有相同长度的所有其他数组成员。(即)str(1)的长度为27601,str(2)、str(3)

我的webmethod返回确切的对象。但是在客户端,javascript不接受值,它会立即触发错误方法

示例代码是

PageMethods.paging("","",pospara,"position_select","stored Procedure",function sucMulti(result){
alert(result);
});
web方法是

<WebMethod()> _
<ScriptMethod()> _
Public Shared Function paging(ByVal query As String, ByVal tbl As String, ByVal para() As Object, ByVal spname As String, ByVal cmdtype As String) As Object()
     Dim dsrt As New DataSet, dbacc As New dataaccess
    If cmdtype = "stored Procedure" Then
        dsrt = dbacc.retds1(spname, conn, para)
    Else
        dsrt = dbacc.retds(query, tbl, conn)
    End If
    'here dsrt will have 19 rows. so i split them by 8.
    Dim no As Integer
    Dim rows As Integer = 8
    Dim r As Integer
    no = Floor(dsrt.Tables(0).Rows.Count / rows)
    If dsrt.Tables(0).Rows.Count < rows Then
        r = 0
    Else
        r = dsrt.Tables(0).Rows.Count Mod rows
    End If

    Dim start As Integer = 0
    Dim last As Integer = 7
    Dim str(0) As Object
    Dim dv As New DataView
    dv = dsrt.Tables(0).DefaultView
    If r <> 0 Then
        no += 1
    End If
    If no >= 1 Then
        ReDim str(no - 1)
        For i As Integer = 1 To no

            Dim ds As New DataSet
            Dim dt As New DataTable
            dt = dsrt.Tables(0).Clone
            dt.Rows.Clear()
            For j As Integer = start To last
                dt.ImportRow(dsrt.Tables(0).Rows(j))
            Next

            start = (rows * i) 
            If r <> 0 And i = no - 1 Then
                last = last + r
            Else
                last = start + 7
            End If
            ds.Tables.Add(dt)
            str(i - 1) = ds.GetXml

        Next
    Else
        str(0) = dsrt.GetXml
    End If
    Dim len As Integer = str(0).ToString.Length
    Return str
End Function
_
_
公共共享函数分页(ByVal查询作为字符串,ByVal tbl作为字符串,ByVal para()作为对象,ByVal spname作为字符串,ByVal cmdtype作为字符串)作为对象()
Dim dsrt作为新数据集,dbacc作为新数据访问
如果cmdtype=“存储过程”,则
dsrt=dbacc.retds1(spname,conn,para)
其他的
dsrt=dbacc.retds(查询、tbl、连接)
如果结束
'这里dsrt将有19行。所以我把它们除以8。
数字编号为整数
将行调整为整数=8
作为整数的Dim r
否=楼层(dsrt.Tables(0).Rows.Count/行)
如果dsrt.Tables(0).Rows.Count<行,则
r=0
其他的
r=dsrt.Tables(0).Rows.Count Mod Rows
如果结束
Dim起始值为整数=0
最后变暗为整数=7
Dim str(0)作为对象
Dim dv作为新的数据视图
dv=dsrt.Tables(0).DefaultView
如果r0那么
否+=1
如果结束
如果否>=1,则
雷迪姆街(1号)
对于i作为整数=1到否
Dim ds作为新数据集
Dim dt作为新数据表
dt=dsrt.Tables(0).Clone
dt.Rows.Clear()
对于j作为整数=从开始到结束
dt.ImportRow(dsrt.Tables(0).行(j))
下一个
开始=(行*i)
如果r0和i=no-1,则
last=last+r
其他的
最后一次=开始+7
如果结束
ds.Tables.Add(dt)
str(i-1)=ds.GetXml
下一个
其他的
str(0)=dsrt.GetXml
如果结束
Dim len As Integer=str(0).ToString.Length
返回str
端函数

一切顺利。str将包含4行,每行将有一个长度为27601的字符串。但是javascript并没有提醒结果。为什么?

我找到了一个解决方案,通过以下方式增加jason最大长度

<system.web.extensions>
<scripting>
  <webServices>
    <jsonSerialization maxJsonLength="5000"/>
  </webServices>
</scripting>

检查这些链接:并且已经检查了no use1),它会给您带来什么错误?2) 搜索“.net webmethod return array of strings”可能会给您提供有用的结果。我的意思是,如果返回字符串的长度超过,将触发onError事件。@andreMorton onError事件应该有一条实际的错误消息。如果你能确切地告诉我们这是什么会有帮助的。似乎不太可能对一根绳子有这么小的限制。请注意,返回的是Object()而不是String()-这是故意的吗?还有,。上次你告诉我们错误消息时,我直接找到了答案,这次告诉我们错误消息怎么样?;)错误消息提到“system.we.extensions”,并用“we”代替“web”。如果这不仅仅是一个输入错误,那么它可能是您第一次输入时留下的错误消息,因此如果重新启动Visual Studio,工具提示错误消息可能会消失。
"the element 'configuration' in namespace 'http://schemas.microsoft.com/.NetConfiguration/v2.0' has invalid child element 'system.we.extensions' in namespace 'http://schemas.microsoft.com/.NetConfiguration/v2.0'. List of possible elements expected: 'system.net' in namespace 'http://schemas.microsoft.com/.NetConfiguration/v2.0'"