为什么我的code返回错误"丢失:物业编号&QUOT后;在JavaScript中? [英] Why does my code return the error "missing : after property id" in JavaScript?
本文介绍了为什么我的code返回错误"丢失:物业编号&QUOT后;在JavaScript中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是应该如何写,以便它的实际工作?
saveBuyerInfo(
{'救_'+ $(#textAreaXMLPostRequest),ATTR('名'):
$(#textAreaXMLPostRequest)VAL()});
解决方案
您不能有前pression作为对象文本的关键。相反,首先创建的对象:
VAR节省= {};
保存['save_'+ $(#textAreaXMLPostRequest),ATTR('名')] = $(#textAreaXMLPostRequest)VAL()。
saveBuyerInfo(保存);
How is this supposed to be written so that it would actually work?
saveBuyerInfo(
{ 'save_'+$("#textAreaXMLPostRequest").attr('name') :
$("#textAreaXMLPostRequest").val() } );
解决方案
You can't have an expression as the key in an object literal. Instead, create your object first:
var save = {};
save['save_' + $("#textAreaXMLPostRequest").attr('name')] = $("#textAreaXMLPostRequest").val();
saveBuyerInfo(save);
这篇关于为什么我的code返回错误"丢失:物业编号&QUOT后;在JavaScript中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文