English 中文(简体)
当我向Node.js服务器发送了联合材料,要求同一物体后再投时,该服务器发送了经修改的物体。
原标题:When I send a JS object to a Node.js server and ask for the same object back, the server sends back a modified object

我有一个网页,建立了与<代码>node.js服务器的通信。 我寄来反对,并交还它收到的同样物体。 然而,返还的物体是不同的,其所有方法都是用的。

这里的法典显示我做什么。 我发出了一个目标:

editor.getSession().on( change , function(event) {
    socket.emit( modificarCodigo , event);
});

我也这样做:

socket.on( modificarCodigo , function(data) {
    socket.broadcast.to(socket.grupo).emit( actualizarCodigo , data);
});

我怎样才能获得<代码>node.js,把我寄给它的物体退回,而不是加以修改? 我有猜测,我现在看到的行为是设计的——如果是这样的话,我如何能够改变?

最佳回答

您不能将职能编为初专干事。 如果你确实需要分配职能,那么你就不得不在以下几条码上填写: <>到String(>>>>,发送,然后送至:>eval <>>>>或“新功能/编号”>,但这是一个风险主张。 为什么你们需要发出方法?

<><>Edit>: 检察官办公室还评论说,他试图做的是通行证和Ace编辑Range。 铁丝上的物体...... 我认为,你最好不要仅仅发送建立新地标所需的数据。 因此,仅仅寄出新电线(数据.startRow,数据启动)。 Col, data.endRow, data.endCol.

作为附带说明,可使用

function Dude(name, age) {
    this.name = name;
    this.age = age;
}
Dude.prototype = {
    speak: function() { alert( My name is   + this.name); },
    toJSON: function() {
        return {
            type:  Dude ,
            props: { name: this.name, age: this.age }
        };
    }
};

http.get( http://getadude.com , function(json) {
    var data = JSON.parse(data);

    if(type ===  Dude ) data = new Dude(data.props.name, data.props.age);
})
问题回答

在寄出该物体之前将物体作为JSON进行编码。 它应当发挥作用。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签