在这个/很长时间之后确定新的......
我创建了一个json列表:
$.ajax({
url: 'http://www.somewebsite.com/land.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data, status) {
$.each(data, function(i, item) {
var balance = '<p>' + item.itemm + ' ' + item.amount + ' ' + item.status +
' ' + '<a href="#" onclick="loadRecord(' + i + ');">edit</a>' + ' ' +
'<a href="#" onclick="deleteRecord(' + item.id + ');"> delete</a>' +
'</p><hr>';
total2 = total2 + parseInt(item.amount);
$("#mylbl").append(balance);
$("#mylbl5").html(total2);
});
},
error: function() {
output.text('There was an error loading the data.');
}
我正在使用此方法,因为我正在使用phonegap ...我有显示项目和添加项目,但想要添加编辑和删除功能......
我正在尝试在每一行上添加编辑和删除链接(如上所述)但只是无法对其进行排序....
仅在删除阶段..并尝试过此删除功能..
function deleteRecord(id) // Get id of record . Function Call when Delete Button Click..
{
mysql_connect("localhost","454547_yeah","password");
mysql_select_db("454487_mydbdb");
var deleteStatement = mysql_query("DELETE FROM balance WHERE id=?");
db.transaction(function (tx) { tx.executeSql(deleteStatement, id, onError); alert("Delete Sucessfully"); });
}
任何帮助或指示非常感谢....我已经在网上搜索过,发现没什么可能有帮助......
答案 0 :(得分:0)
你可以尝试这个
formDataEdit = {
itemm: $("#itemm"),
amount: $("#amount"),
status: $("#status")
};
$.ajax({
url: 'http://www.somewebsite.com/delete.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
data: formDataEdit,
success: function(data, status) {
alert("Edit successful");
},
error: function() {
output.text('There was an error loading the data.');
}
});
formDataDelete = {
id: $("#id")
};
$.ajax({
url: 'http://www.somewebsite.com/delete.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
data: formDataDelete,
success: function(data, status) {
alert("Delete successful");
},
error: function() {
output.text('There was an error loading the data.');
}
});
HTML
<b><a onclick="edit(1);">Edit</a> | <a onclick="delete(1);">Delete</a></b>
JS
currentPage = {};
currentPage.edit = function(id){ //also can use for delete
alert(id);
};