Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Diego_F_
Beginner
84 Views

Why in the XDK emulator works perfect, but does not work in mobile ?

 

Help me, please!  I made a small test with a list with ajax that brings json encode data. In the emulator XDK, it worked perfectly, but in the mobile,dont show anything.

code below:

    $.ajax({
        type:"GET",
        url: "http://192.168.25.15/index.php/?acao=listar_categoria",
        contentType: "application/json; charset=utf-8",
        success: function (result, jqXHR) {
             var retorno = JSON.parse(result);

                  $.each(retorno,function(i, categoria){
                         
                         var item = '<li><h1 id="'+categoria.id+'"><img src="images/'+categoria.nome+'.png" />'+categoria.nome+'</h1></li><hr align="left">'; 
                        
                      
                $("#lista").append(item);
                                      })    

        }
 
    })

 

ps:debug does not show errors!

Tags (2)
0 Kudos
8 Replies
Diego_Calp
Valued Contributor I
84 Views

Hi,

If you put 

http://192.168.25.15/index.php/?acao=listar_categoria

In your mobile's browser, do you get something?

Check also the whitelisting options in XDK Projects / Build settings.

Regards,

Diego

Diego_F_
Beginner
84 Views

Yes, Browser shows me the data!

[{"id":"4","nome":"Aulas Particulares"},{"id":"1","nome":"Casa"},{"id":"5","nome":"Cuidados Pessoais"},{"id":"3","nome":"Festas"},{"id":"6","nome":"Pets"},{"id":"2","nome":"Transporte"}]

the value of the whitelist is *

I added the file plugins and file transfer and the meta-tag

<meta http-equiv="Content-Security-Policy" content="default-src *;connect-src * style-src * 'unsafe-inline'; script-src *  'unsafe-inline' 'unsafe-eval'"/>

But but it did not work.

Any idea?

 

 

Diego_Calp
Valued Contributor I
84 Views

Perhaps is CORS configuration, read about it and check this:

http://enable-cors.org/server_php.html

 

Rakshith_K_Intel
Employee
84 Views

Have you included cordova.js in index.html ?

Can u share the actual url in private message, i can check.

Diego_F_
Beginner
84 Views

 

Yes, I had included both cordova.js as CORS.

I think this problem is related to the App Preview because I built the application and installed on my phone.

Conclusion, everything worked, only the App Preview that did not work.

thank you guys, great to have your help.

Rakshith_K_Intel
Employee
84 Views

@Diego F. which App Preview - android or ios ?

PaulF_IntelCorp
Employee
84 Views

There are AJAX problems in the latest Cordova frameworks if you use jQuery 1.x libs, you might want to switch to jQuery 2.x libs. See this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail

Diego_F_
Beginner
84 Views

Rakshith Krishnappa (Intel)  Android.

I read the faq and did what was indicated.

I changed the jquery version to version 2.0.0 and doenst work, then I put the version 2.3.3 and nothing.

I Dont use the App Designer.

My App Preview version is 2.8.1.

 

 

 

Reply