jQuery integration

Find out how to integrate JSQL with jQuery

Stack requirements

The JSQL jQuery library will not work without an account in the JSQL cloud, a backend application (API) integrated with JSQL and integration with the tasks of the runner. To learn more see overview.

Installation

Install via NPM

npm install jsql-jquery

To include library in your project include library in your HTML or include into your tasks runner configuration.

<script src="jsql-jquery.min.js"></script>

Or use bundled version with included latest jQuery:

<script src="jsql-jquery-bundle.min.js"></script>

Usage

First of all, you need to initiate JSQL object:

var jsql = new JSQL({
 host: 'https://mysite.com/
});

Then you can execute operational functions as on example below:

Example select usage

var jsql = new JSQL({
host: 'https://mysite.com/'
});

jsql.select('select * from person')
.done(function(result){
// Query result
})
.fail(function(error){
// Database errors
});

For details on using other methods like delete, update, insert and binding parameters, see the documentation.

Promises naming

Each implementation of the JSQL library for the framework has a slightly different promises structure.

For jQuery we use jQuery AJAX default convention using done and fail and always names instead of then and catch.

Example promise naming

jsql.select('select * from person')
.done(function(result){
// Query result
})
.fail(function(error){
// Database errors
})
.always(function(){
// Always executed
});
Close Menu