Why this jquery code is not working on blackberry?

Deadly 提交于 2019-12-10 21:27:27

问题


I am developing phonegap app using jquerymobile.

but in blackberry 9780 it does not show me alert, my code is

document.addEventListener('deviceready', run, false);

function run(){
            $.getJSON('http://twitter.com/users/usejquery.json?callback=?', function(json){  

                alert(json.followers_count); // not displaying in blackberry
            });
        }

My head part is :

        <script src="phonegap.js">
        </script>
        <script src="jquery1.6.2.js">
        </script>
        <script src="jquery.mobile1.0b3.js">

It works fine in other mobiles like Android,iphone,ipad and also working on my Mozzila browser 8.0 but not working on blackberry OS 6.

Please help me.

Thanks


回答1:


1st make sure that run() is getting executed, if not, then try attachEvent element.attachEvent('ondeviceready',run)

Edit

refer

JQuery JSONP cross domain call not doing anything and jQuery, JSON and Apache problem




回答2:


A few things:

  1. there is a new version of jqm, the v1.0 RC1, try to work with this one.
  2. Use the Ripple Emulator from RIM to test more quiccly the app, is a Chrome broser plugin.

And the most important:

deviceready needs:

  1. in your body make this: <body onLoad='initSO()'>

then in the header, after loading: json2.js, phongap, jquery, jquerymobile... put this

function initSO() {
            console.log('initSO()');
           document.addEventListener("deviceready", onDeviceReadySO, true); 
}

function onDeviceReadySO() {
console.log('hello word :D ');
}


来源:https://stackoverflow.com/questions/7632284/why-this-jquery-code-is-not-working-on-blackberry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!