[英]How to display data from mysql with id sent with javascript ( Adobe Phonegap )
I make a menu link with javascript. 我用javascript制作菜单链接。 By using the parsing in php I display a menu with the help of javascript.
通过使用php中的解析,我借助javascript显示了一个菜单。 The problem is how do I display data in accordance with the "id" which has been on the destination page.
问题是如何根据目标页面上的“ id”显示数据。
Here's the code in index.html 这是index.html中的代码
function loadkategori(idnya){
$('#contentID').load('kategori.php?id='+idnya, function(){
$('#myListview').listview().listview('refresh');
});
}
$(document).ready(function(){
$.ajax({
url: 'http://localhost/fiqi/fiqi2/kuliner/www/parsing2.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data, status){
$.each(data, function(i,item){
// $("#listview").append("<li><a href=#><img src="+item.lokasigambar+"><h2>"+item.namatempatnya+"</a><p>Kalimat</p></h2></li>");
// seharusnya menggunakan class, tidak inline function
$('#listview').append('<li data-filtertext="form checkboxradio widget checkbox input checkboxes controlgroups" onclick="loadkategori('+item.idkat+')"><a href="" data-ajax="false">'+item.namakategori+'</a></li>');
});
// $("#listview");
// $('ul').listview('refresh');
$('#listview').listview().listview('refresh');
// $('#element').collapsibleset('refresh');
},
error: function(){
alert('Error terjadi');
}
});
});
here's the code in kategori.php 这是kategori.php中的代码
The code in kategori.php doesn't work on adobe phonegap. kategori.php中的代码不适用于Adobe Phonegap。
I couldn't implement you code but as far as i understand, You need to use some http request function to get data from serverside php rather than using load(), go for using $.get(). 我无法实现您的代码,但据我了解,您需要使用一些http请求函数来从服务器端php获取数据,而不是使用load(),而要使用$ .get()。 That might work out as a solution to your problem.
可以解决您的问题。
function loadkategori(idnya){ 函数loadkategori(idnya){
var data = $.get('kategori.php?id='+idnya, function(data,status){
//PROCESS YOUR DATA OR CALL YOUR FUNCTION TO POPULATE YOUR LISTVIEW
});
}
Secondly you should use either xml or json data for client server communication. 其次,您应该使用xml或json数据进行客户端服务器通信。 That would make your program simple and more efficient.
这将使您的程序简单而高效。 You might paste your php code instead of putting screenshot so that some editing or testing can be done.
您可以粘贴您的php代码而不是放置屏幕截图,以便可以进行一些编辑或测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.