来自 BackboneJS 的 Ajax 调用

Ajax call from BackboneJS

本文关键字:调用 Ajax BackboneJS 来自      更新时间:2023-09-26

如何从返回字符串的 mvc 控制器的主干操作调用。我需要能够稍后在javascript中使用该字符串。关于来自控制器的调用操作。我只需要与jquery类似的功能:

$.ajax({
            type: 'POST',
            url: window.location + "Home/InsertRecord",
            data: {ID : newPersonName},
            success: function(data) {
                // Code after success },
                error: function(){
                    alert("error");
                }
            });
来自

骨干网的Ajax调用.js

//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