主干通过 AJAX 向服务器发送参数
嘿, 我对骨干网很陌生,我读了一些文档,但没有找到合适的东西。我想使用骨干网通过 AJAX 通信将一些数据发送到服务器。骨干有某种捷径可以做到这一点吗?现在,我的简单示例由一个 HTML 页面组成,其中包含一个用户名输入和一个密码输入。单击按钮后,我会触发此功能:
//handling the button event on the login form
function loginPressed(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
loginModel.username = username;
loginModel.password = password;
}
登录模型只是我用主干创建的模型:
//creating a backbone model to handle login
var loginModel = new Backbone.Model({
username: "",
password: "",
});
您认为我可以用它向我的服务器发出 AJAX 请求吗?
谢谢, 马西亚尔
我的服务器端是node.js
Hey,
I'm very new to backbone, and I've read a little bit of the documentation but I didn't find something appropriate. I would like to use backbone to send some data to the server using AJAX communication. Does backbone have some kind of shortcut to do this? For now my simple example consist of a HTML page with an input for username and one for the password. On clicking the button I fire this function:
//handling the button event on the login form
function loginPressed(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
loginModel.username = username;
loginModel.password = password;
}
The login model is just a model I've created with backbone:
//creating a backbone model to handle login
var loginModel = new Backbone.Model({
username: "",
password: "",
});
Do you think I can do AJAX request to my server with this?
Thanks,
Masiar
P.S. My serverside is node.js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的模型定义不正确:
有一些原因您不应该使用 ajax 调用登录,但您很快就会学到它们:)
Your model is not defined properly:
There are some reasons you should not do login with ajax calls but you'll learn them soon enough :)