为什么有时会发送变量而有时不发送? [英] Why is a variable sometimes sent and other times not?

查看:74
本文介绍了为什么有时会发送变量而有时不发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网页上我有两种形式。第一个创建静态,第二个动态创建(根据请求)


两个表单对服务器进行相同的ajax调用。

两者都使用相同的javaScript例程来进行调用。

两者都调用相同的服务器端应用程序。


我存储了变量/数组中的数据appData这是我JSON编码的。


在服务器端应用程序中,我查找JSON元素appData并解码它。

当动态表单发出请求时,
appData不存在。


这是我的代码和屏幕截图,代码停止显示变量的内容。


这是我的ajax例程

展开 | 选择 | Wrap | 行号

解决方案

您的PHP脚本似乎有问题。您是否手动检查了它的输出?


看起来您的第二个输出是您的反序列化的appData对象。


PS。 encodeURIComponent()


这是我问题的症结所在。当我遇到问题时,我试图对数据进行反序列化。


从我用两行代码编写的测试应用程序中可以看到,我在同一个调用中仍然有两个不同的响应。


我使用firePHP检查输出。不确定我还能做什么。


我刚刚在php应用程序中运行了快速转储。它简单地确认了我在firePHP中看到的内容。


array(6){[" SEARCH"] => string(4)clau [" TABLE"] => string(13)contactCLIENT [" INDEX"] => string(2)" ID" ["字段名"] => string(6)" Client" [" SETMODE"] => string(3)是 [" SearchMethod"] => string(9)" StartWith" }

On the web page I have two forms. The first created statically, the 2nd created dynamically (upon request)

Both forms make the same ajax call to the server.
Both use the same javaScript routines to make the call.
Both call the same server side app.

I store the data in a variable/array "appData" which I JSON encode.

On the server side app, I look for the JSON element "appData" and decode it.

appData is not present when the dynamic form makes the request.

Here is my code and screen shots of where the code was halted to show the content of the variables.

This is my ajax routine

Expand|Select|Wrap|Line Numbers

解决方案

there seems to be a problem with you PHP script. did you manually check its output?

it looks like your second output is your deserialised appData object.

PS. encodeURIComponent()


well that is the crux of my problem. I was trying to deserialised the data when I ran into the problem.

As you can see from the test app I wrote with just the two lines of code, I still got two different responses on the same call.

I use firePHP to check the output. Not sure what else I can do there.


I just ran a quick dump in the php app. It simply confirms what I see with the firePHP.

array(6) { ["SEARCH"]=> string(4) "clau" ["TABLE"]=> string(13) "contactCLIENT" ["INDEX"]=> string(2) "ID" ["FieldName"]=> string(6) "Client" ["SETMODE"]=> string(3) "Yes" ["SearchMethod"]=> string(9) "StartWith" }


这篇关于为什么有时会发送变量而有时不发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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