Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : ajax call to database example

$
0
0
So, if I code my recipe.js file as follows, is that ok?

steal('jquery/model', function(){

/**
 * @class Cookbook.Models.Recipe
 * @parent index
 * @inherits jQuery.Model
 * Wraps backend recipe services. 
 */

$.Model('Cookbook.Models.Recipe',
/* @Static */
{

    findAll: function(params, success, error){
        var vars = "{ 'tableName' : 'recipe', 'id' : '' }";
        var response = $.ajax({
           type: "POST",
           url: "/WebService1.asmx/recipes",
           dataType: "json",
           contentType: "application/json",
           data: vars
        });
        return response.d;
    },
    findOne : "/recipes/{id}.json",
    create : "/recipes.json",
    update : "/recipes/{id}.json",
    destroy : "/recipes/{id}.json"

},
/* @Prototype */
{});

})



Viewing all articles
Browse latest Browse all 3491

Trending Articles