Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Add JavaScript Error Handling

Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland asked on
6 Comments1 Solution244 ViewsLast Modified:
Hi All,

I have the following code that works well in Chrome, but when I run it on a Blackberry if doesn't work.

Could someone help help adding the on success/error handlers so I can tell whats happening.

<!DOCTYPE html>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>AMS - CRM</title>
		<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
		<script type="text/javascript">
				// JSON data url
					var url="https://mydomain.com/json.php";

				$("#status").html("<p>Loading data... please wait</p>");

				// <INSERT DATA>
					$.getJSON(url, function(data){
						db.transaction(function (tx) {
							// <create database>
								tx.executeSql('DROP TABLE IF EXISTS CRM');
								tx.executeSql('CREATE TABLE IF NOT EXISTS CRM (id unique, customer, contact)');
							// </create database>
							$.each(data.users, function(i,user){
								var sql_id			= user.id;
								var sql_company		= user.company.replace(/'/g,"\\'").replace(/"/g,'')	// comment out quotes
								var sql_contact		= user.contact.replace(/'/g,"\\'").replace(/"/g,'')	// comment out quotes

								tx.executeSql('INSERT INTO CRM (id, customer, contact) VALUES ('+sql_id+', "'+sql_company+'","'+sql_contact+'")');

				// </INSERT DATA>


	<div id="status"></div>

Many thanks