Jquery-mobile: doesn't insert data to database
Here's the html:
<div data-role="page" id="new">
<div data-role="header">
<h1>New Note</h1>
</div>
<div data-role="content">
<form action="" method="post" name="insert" id="insert" data-ajax="false">
<div data-role="fieldcontain">
<label for="title">Title:</label>
<input type="text" name="title" id="title" value="" />
</div>
<div data-role="fieldcontain">
<label for="details">Details:</label>
<textarea cols="40" rows="8" name="details" id="details"></textarea>
</div>
<input name="create" type="submit" id="create" value="Insert" />
</form>
</div>
</div>
and here's the javascript insert:
$(function() {
$('#new').live('pageshow', getLocation);
$('#insert').live('submit', insertEntry);
});
var rtNotes = {
lat: null,
ln开发者_JS百科g: null,
limit: 20
};
function insertEntry(e) {
var title = $('title').val(),
details = $('details').val();
$.mobile.notesdb.transaction(function(t) {
t.executeSql('INSERT into notes (title, details, entered, latitude, longitude) VALUES (?,?,date("NOW"),?,?);',
[title, details, rtNotes.lat, rtNotes.lng],
function() {
$.mobile.changePage('#home', 'slide', false, true);
$('#title').val('');
$('#details').val('');
},
null);
});
e.preventDefault();
};
When insert button is pressed it doesn't insert to sql and doesn't change page.
精彩评论