如何修复vb和javascript之间的类型不匹配错误? [英] How do I fix a type mismatch error between vb and javascript?

查看:87
本文介绍了如何修复vb和javascript之间的类型不匹配错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将变量从我的visual basic数组传递到我的javascript。数据正从访问数据库中提取。以下是我的代码示例:



嵌入式javascript的可视基本代码:

I am having trouble passing variables from my visual basic array to my javascript. The data is being pulled from an access database. Here is a sample of my code:

visual basic code with embedded javascript:

Dim i
    for i=0 to numRecords-1
    datelabels(i) = rsGraph("DM")
    waterlevels(i) = rsGraph("WLVB")
    rsGraph.MoveNext
    next





...





...

Response.Write("$(document).ready(function(){")

 'type mismatch Microsoft VBScript runtime error '800a000d' 

    Response.Write("var waterArray = ['" & datelabels & "'," & waterlevels & "];")

Response.Write("var plot2 = $.jqplot('chart2', [waterArray], {")





...



我在想,也许我需要在我的var waterArray阵列周围的另一个环路。感谢任何帮助。



Liz



...

I was thinking that maybe I needed another for loop somewhere around my "var waterArray" array. Any help is appreciated.

Liz

推荐答案

(document).ready(function(){)

' 类型不匹配Microsoft VBScript运行时错误' 800a000d '

Response.Write(var waterArray = ['
& datelabels& ' ,& waterlevels&];)

Response.Write(var plot2 =
(document).ready(function(){") 'type mismatch Microsoft VBScript runtime error '800a000d' Response.Write("var waterArray = ['" & datelabels & "'," & waterlevels & "];") Response.Write("var plot2 =


.jqplot(' chart2 ' ,[waterArray],{)
.jqplot('chart2', [waterArray], {")





...



我想我可能需要在我的var waterArray数组周围的另一个for循环。任何帮助表示赞赏。



Liz



...

I was thinking that maybe I needed another for loop somewhere around my "var waterArray" array. Any help is appreciated.

Liz


至少有两个重要原因没有这样的问题。



首先,不能存在VB和JavaScript之间的类型不匹配,因为JavaScript根本没有相同意义上的类型VB(无论它是什么:-))类型是了解。 JavaScript类型只有8到9(一个是依赖于实现的)并且由字符串描述:undefined,null,string......object,(而.NET或非.NET VB)允许任何数字不同类型。另请参阅: https://developer.mozilla.org/en-US/docs / Web / JavaScript / Reference / Operators / typeof [ ^ ]。



第二个原因是:如果您使用的是ASP.NET或任何其他Web技术(还有许多其他的非Web技术),你从来没有在JavaScript和服务器端对象之间进行任何交换。决不。相反,您只需在服务器端生成一些JavaScript文本并将其放入HTTP响应中。 Web浏览器获取HTTP响应,相应地解析和处理它,最终可能导致执行某些JavaScript代码。 您需要将服务器端生成的JavaScript视为纯文本。这就是全部。



现在,以上是解决方案的关键。首先,在浏览器中打开页面,使用View - >页面源(或类似的东西,取决于您的浏览器)并检查实际生成的JavaScript文本。确保它是正确的。如果没有,请找出服务器端出错的地方,您可以使用调试器。这就是全部。



-SA
There is no such problem by at least two important reasons.

First of all, there cannot be "type mismatch between VB and JavaScript", because JavaScript simply does not have the types in the same sense VB (whatever it is :-)) types are understood. JavaScript types are only 8 to 9 (one is implementation-dependent) and are described by strings: "undefined", "null", "string"… "object", (while .NET or non-.NET VB) allow any number of distinct types. See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof[^].

The second reason is this: if you are using ASP.NET or any other Web technology (and also a number of other, non-Web technologies), you never have any exchange between JavaScript and server-side objects. Never. Instead, you just generate some JavaScript text on the server side and put it in HTTP response. A Web browser gets the HTTP response, parses and handle it accordingly, which ultimately may lead to execution of some JavaScript code. You need to consider the JavaScript generated on server side as pure text. That's all.

Now, the above is the key to the solution. First of all, open the page in your browser, use View -> Page Source (or something like that, depending on your browser) and inspect actually generated JavaScript text. Makes sure it is correct. If not, find out what's wrong is going on the server side, where you can use the debugger. That's all.

—SA


这篇关于如何修复vb和javascript之间的类型不匹配错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆