开发者

How can get value in phonegap which is returned by php class?

开发者 https://www.devze.com 2023-03-29 11:20 出处:网络
I am designing a project inphonegap with android. i want to show the name using alert message in phonegap which is returned by my php class.

I am designing a project in phonegap with android. i want to show the name using alert message in phonegap which is returned by my php class. This is my php class:

<?php

final class DataStrip
{
        public function DataStrip()
        {
                return "kuntal";  
        }


}
?>

Now in my phonegap program i want to display this "kuntal" by using alert. please help me what will be code to do 开发者_JS百科this functionality in phonegap. please check my php class also.


Have your php return a JSON object:

final class DataStrip
{
        public function DataStrip()
        {
                return json_encode(array("result"=>"kuntal"));  
        }


}
?>

Then in your PhoneGap application, use ajax to get the JSON and alert it (example uses jQuery for brevity):

$.getJSON('http://www.domain.com/mypage.php', function(data) {
    alert(data.result);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消