利用骨干网将数据放入其余服务器 [英] using backbone to put data into rest server

查看:143
本文介绍了利用骨干网将数据放入其余服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。

如果我有一个名为输入模式。它包含模型发票和收集InvoiceDetailCollection。

If i have a model named Input. It contains model Invoice and Collection InvoiceDetailCollection.

我修改了Backbone.js的创建专门:POST到创造:PUT序允许PUT因为我的服务不使用POST

I modified the backbone.js specifically create:"POST" into create:"PUT" inorder to allow PUT since my service doesn't use POST.

如果我是用Input.save()应该是什么我的服务器期望作为请求?我的意思是已经设置了服务方法期望的字符串,因为如果我希望我的字符串不能使用input.save();

If i were to use Input.save() What should my server expect as a request? I mean already have set a service method to expect string since if i expect string i can't use the input.save();

应该是什么我应该期待在我的服务器端合适的参数,如果我是使用Backbone.js的的Input.save()方法

What should be the right parameter i should expect on my server side if i were to use the Input.save() method of backbone.js

推荐答案

默认情况下,骨干传送应用程序/ JSON数据和服务器应该期待JSON数据。你会想脱code吧。我使用PHP和中间件,可以自动json_de code($数据),并把它变成一个关联数组我来操纵。

By default, Backbone sends application/json data and the server should expects JSON data. You'll want to decode it. I use PHP and middleware that automatically json_decode($data) and turns it into an associative array for me to manipulate.

如果这是不可能的,(不能拿JSON数据),我想你想要的是使用 emulateJSON 这将序列化的数据并将其作为应用程序/ X WWW的形式,urlen codeD就像一个HTML表单。

If this isn't possible, (can't take JSON data) I think what you want is to use emulateJSON It will serialize your data and send it as application/x-www-form-urlencoded like an HTML form.

http://documentcloud.github.com/backbone/#Sync-emulateJSON

这篇关于利用骨干网将数据放入其余服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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