如何从mvc控制器调用骨干操作,返回一个字符串。我需要能够在javascript中使用该字符串。从控制器调用操作。我只需要与jquery类似的功能:
$.ajax({
type: 'POST',
url: window.location + "Home/InsertRecord",
data: {ID : newPersonName},
success: function(data) {
// Code after success },
error: function(){
alert("error");
}
});
答案 0 :(得分:0)
来自backbone.js的Ajax调用
//Model Declaration
var mod = Backbone. Model. extends ({});
var collection = Backbone.Collection.extend({
model:Model
});
//Create Collection Object
newCollection = new collection();
//Make Ajax Call
Backbone.ajax({
dataType: "jsonp",
url: "http://example.com", //Replace your URL here
data: "", //add your data
success: function(response){
//code after success
}
error: function () {
// Code After Erroe
}
}).complete(function () {
//Code after complete the request
});
供参考,请查看此链接 http://backbonejs.org/#Model