JavaScript 字面量,键的指针值
我有以下代码:
name= "a";
value="b"
$.post("ajax.php", {name:value})....
但是 ajax.php
将收到 name=b
而不是 a=b
。
我如何让它收到后者?
I have the following code:
name= "a";
value="b"
$.post("ajax.php", {name:value})....
However ajax.php
will receive name=b
instead of a=b
.
How would I make it receive the latter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
为了获得您想要的效果,您可以执行以下操作...
To get the effect you desire you can do the following...
这里的名称不被视为可替换...
您应该手动编写:
The name here is not treated as to be replaceable ...
you should manually write :
您不能对关键元素使用变量(如果您考虑使用文字声明)。它必须是静态的
你需要这样做:
You can't use a variable for key element (if you consider using literal declaration). It has to be static
You need to do this:
不过,您也许能够以编程方式构建该对象。您可以通过这种方式创建一个对象:
所以尝试这个:
并将其传递给 post 调用...
You may be able to build the object programmably though. You can create an object in this way:
So try this:
And pass that to the post call...