2014-12-05 57 views
1

如何從mvc控制器調用返回字符串的骨幹動作。我需要能夠以後使用該字符串在javascript.Regarding呼籲從controller.I動作只需從jQuery的功能類似於此:來自BackboneJS的Ajax調用

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

回答

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

+0

謝謝你它幫了我很多 – meer 2014-12-11 11:11:11

+0

@meer你好:) – 2014-12-11 11:35:18

相關問題