Software Archive
Read-only legacy content
17061 討論

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

Diego_F_
初學者
1,484 檢視

 

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!

0 積分
8 回應
Diego_Calp
傑出貢獻者 I
1,484 檢視

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_
初學者
1,484 檢視

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
傑出貢獻者 I
1,484 檢視

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

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

 

Rakshith_K_Intel
1,484 檢視

Have you included cordova.js in index.html ?

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

Diego_F_
初學者
1,484 檢視

 

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
1,484 檢視

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

PaulF_IntelCorp
1,484 檢視

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_
初學者
1,484 檢視

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.

 

 

 

回覆