有时在生产服务器上未定义JSON数组。 [英] JSON array is undefined sometimes on production server.

查看:74
本文介绍了有时在生产服务器上未定义JSON数组。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我遇到过这样的情况,我在Node JS平台上开发了应用程序,该平台从Sqlite数据库中获取数据。



我在server.js上采用了全局变量,这只是一个NodeJS代码。

这个全局变量我在server.js的顶部声明了像

var UniqueUsers;



我在Node JS方法中为这个变量赋值。

UniqueUsers = JSON .stringify(result);

结果只是来自Sqlite DB的数据。



我使用Kendopivot网格来渲染数据。该网格具有链接按钮/锚标记。当我点击它们然后我在某些条件下从UniqueUsers变量上面获取记录并在弹出窗口显示用户信息。



我动态创建HTML文件并访问以上变量为: -

Hi All,

I have came across a situation, i have develped application on Node JS platform which fetches data from Sqlite Database.

I have taken global variable on server.js which is nothing but a NodeJS code.
This global variable i have declared at the top of server.js like
var UniqueUsers;

And i am assigning this variable a value in Node JS method.
UniqueUsers = JSON.stringify(result);
Where result is nothing but data from Sqlite DB.

I am using Kendopivot grid to render data. This grid have link button/anchor tag. When i click on them then i am fetching record from above UniqueUsers variable based in some condition and showing user information on popup window.

I am dynamically creating HTML file and accessing above variable as :-

<pre lang="Javascript">

< meta http-equiv =X-UA-Compatible content =IE = edge; chrome = 1/> \\\\ n< meta charset =utf-8/>



var unique_user ='+ UniqueUsers +';

$(窗口).load(function()

{

console.log(unique_user);

//动态创建html标签

//显示用户信息

});



这完全适用于我当地的环境。每当我点击链接时,用户信息显示。

我的意思是JSON变量未定义。



但是当我访问我的网站时生产服务器,然后单击任何链接,然后JSON未定义。

然后没有任何反应,加载图像显示。数据无法加载。

没有出错。

即使我在控制台上打印json结果。但是它显示为undefined。

第一次点击链接 - 然后json未定义。

第二次点击链接 - 它显示记录。

当我点击链接时第三次 - json未定义。

意味着每个替代,它都在发生。




我验证了服务器上的所有css和js文件,并且所有文件都放在了正确的位置。

在chrome上,它正在工作但有时也会变得不确定。



有时当我将IE兼容模式从边缘更改为10或10更改为Edge时,它可以正常工作。



我也想知道为什么会发生这种情况在服务器端。

有人可以告诉我。什么会导致json未定义。



我尝试过:



我已尽力而为但无法解决上述问题。

正如已经说过的那样,在本地环境下它正在运行。

<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1" />\r\n<meta charset="utf-8" />

var unique_user =' + UniqueUsers + ';
$(window).load(function()
{
console.log(unique_user);
//dynamically creating html tags
//showing user information
});

This is perfectly working on my local environment. Everytime when i click on link, user information shows.
I mean JSON variable is not undefined.

However when i access my site on production server and click on any links then JSON is undefined.
Then nothing happens and loading image is showing. Data does not load.
No error has been raised.
Even I am printing json result on console. But it dsplays as undefined.
First time when i click on link - then json is undefined.
Second time when i click on link - it shows records.
Third time when i click on link - json is undefined.
Meaning every alternate, it's happening.


I verified all the css and js files on server and all placed on right place.
On chrome, it's working but sometimes also getting undefined.

Sometimes when i change IE compatibility mode from edge to 10 or 10 to Edge, then it works.

I am also wondering why this happens on server side.
Can anybody let me know please. What would be causing json to undefined.

What I have tried:

I have tried all my way but not able to resolve above issue.
And as already said that, on local environment it's working.

推荐答案

(window).load(function()

{

console.log(unique_user);

//动态创建html标签

//显示用户信息

});



这完全适用于我的本地环境。每当我点击链接时,用户信息显示。

我的意思是JSON变量未定义。



但是当我访问我的网站时生产服务器,然后单击任何链接,然后JSON未定义。

然后没有任何反应,加载图像显示。数据无法加载。

没有出错。

即使我在控制台上打印json结果。但是它显示为undefined。

第一次点击链接 - 然后json未定义。

第二次点击链接 - 它显示记录。

当我点击链接时第三次 - json未定义。

意味着每个替代,它都在发生。




我验证了服务器上的所有css和js文件,并且所有文件都放在了正确的位置。

在chrome上,它正在工作但有时也会变得不确定。



有时当我将IE兼容模式从边缘更改为10或10更改为Edge时,它可以正常工作。



我也想知道为什么会发生这种情况在服务器端。

有人可以告诉我。什么会导致json未定义。



我尝试过:



我已尽力而为但无法解决上述问题。

正如已经说过的那样,在当地环境下,它正在发挥作用。
(window).load(function()
{
console.log(unique_user);
//dynamically creating html tags
//showing user information
});

This is perfectly working on my local environment. Everytime when i click on link, user information shows.
I mean JSON variable is not undefined.

However when i access my site on production server and click on any links then JSON is undefined.
Then nothing happens and loading image is showing. Data does not load.
No error has been raised.
Even I am printing json result on console. But it dsplays as undefined.
First time when i click on link - then json is undefined.
Second time when i click on link - it shows records.
Third time when i click on link - json is undefined.
Meaning every alternate, it's happening.


I verified all the css and js files on server and all placed on right place.
On chrome, it's working but sometimes also getting undefined.

Sometimes when i change IE compatibility mode from edge to 10 or 10 to Edge, then it works.

I am also wondering why this happens on server side.
Can anybody let me know please. What would be causing json to undefined.

What I have tried:

I have tried all my way but not able to resolve above issue.
And as already said that, on local environment it's working.


这篇关于有时在生产服务器上未定义JSON数组。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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