简体   繁体   English

如何显示以javascript发送的id为mysql的数据(Adobe Phonegap)

[英]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中的代码 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.

相关问题 Javascript未加载mysql数据phonegap - Javascript not loading mysql data phonegap 如何使用来自通过Flex URLRequest发送的POST数据的javascript在HTML页面上显示文件? - How to display a file on an HTML page with javascript from POST data sent via a Flex URLRequest? 如何使用mysql的javascript提取格式显示数据? - how to display data in format using javascript extract from mysql? 如何将值从 JavaScript 发送到表单并获取该值作为表单 ID - How to sent a value from JavaScript to a form and get the value as form id 如何从网址获取变量中的数据。 javascript / phonegap - how to get data in variable from url. javascript/phonegap 如何在iPhone的Phonegap应用程序中的javascript中从sqlite3读取数据 - How to read the data from sqlite3 in javascript in phonegap application for iphone 使用JavaScript从ID3图像数据显示图像 - Display image from ID3 image data using javascript 如果与 id javascript 匹配,则显示从 object 中选择的数据 - Display selected data from object if it matches with id javascript 如何使用Javascript读取从Android发送的JSON数据? - How to read JSON data, that is sent from Android, using Javascript? 如何使用javascript查看快递发送的json数据? - How to view json data sent from express using javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM