简体   繁体   中英

Jquery internal ajax (get) not working on phonegap + android 2.2

I don't know for sure if the problem is in the request or in the display of the results, but this is not working for me, when I tap on the link on the phone I get a white screen, on desktop (Chrome) works without problems.

$('a').on('click', function(click_event){
  $.get($(this).attr('href'),function(response_text){
    $('body').html(response_text)           
 })
 click_event.preventDefault()
 return false
})

'Debugging' with weinre it tells me it enters on the get function... I'm using PhoneGap Build and have not set a config.xml, but when I install the app on the phone, it ask permission to access to the Internet...

Any help would be appreciated.

What is the URL within the href?

Is it an external URL or a local path?

If the latter, read in to the Whitelist Guide here...

http://docs.phonegap.com/en/2.5.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide

I solved the problem by adding the last parameter 'dataType' as 'html' on the get call, for some reason it was assuming another type of content (xml or json I guess). Everything is working fine now :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM