0
var User = Backbone.Model.extend({
defaults: {
user_name: "",
user_email: "",
user_password: "",
},
initialize: function() {
console.log('user has been intialized');
},
urlRoot: 'http://localhost/reddit/index.php/user_account/user'
});
$(document).ready(function(){
$("#submit").click(function(){
var email = $("#uname").val();
var password = $("#upass").val();
if(email==''||password=='')
{
alert("Please Fill All Fields");
}
else
{
// AJAX Code To Submit Form.
var user = new User({user_email: email, user_password:password});
user.fetch({
success: function() {
var view1 = new SampleView({model: user, el: $("#logged_user")});
view1.render();
}
});
}
return false;
});
});
這是我的代碼。我需要在codeigniter中將user_name和user_password發送給控制器。我檢查了從控制器中的視圖發送的值。那些是空的。誰能幫我 ?由於發送表單數據到控制器使用骨幹js
'.fetch'將GET請求不發送任何數據。嘗試使用'user.save()',它會發出一個POST請求或者只是調用一個自定義的jQuery'.ajax'調用。 –