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

Re : ajax call to database example

$
0
0
The static methods findAll, findOne, create, update and destroy return a Deferred. If you look at their corresponding documentation,  you'll see how to implement your own using a function.

The simplest way to implement them is using a string that is the URL that will be used in the Ajax call. Any parameters you pass in to each call will be passed along to your backend service.

So if findAll is defined as '/recipes'

Then this call:
  1. Cookbook.Models.Recipe.findAll({order: 'name ASC'})
Would result in an Ajax call like this:
  1. $.ajax({
  2.       url: '/recipes',
  3.       type: 'get'
  4.       data: 'order=name ASC'
  5. })

Viewing all articles
Browse latest Browse all 3491

Trending Articles