Jquery内部ajax (get)不能在phonegap + android 2.2上工作

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

本文关键字:phonegap android 工作 不能 ajax 内部 get Jquery      更新时间:2023-09-26

我不确定问题是在请求还是在结果的显示中,但这对我不起作用,当我点击手机上的链接时,我得到一个白屏,在桌面(Chrome)上工作没有问题。

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

'Debugging' with where,它告诉我它进入了get函数…我正在使用PhoneGap Build并且没有设置config.xml,但是当我在手机上安装该应用程序时,它要求允许访问互联网…

href中的URL是什么?

是外部URL还是本地路径?

如果是后者,请阅读此处的白名单指南…

http://docs.phonegap.com/en/2.5.0/guide_whitelist_index.md.html域% 20白名单% 20指南

我通过在get调用上添加最后一个参数'dataType'作为'html'来解决问题,由于某种原因它假设了另一种类型的内容(xml或json我猜)。现在一切正常