我正在尝试在黑莓上使用PhoneGap提交XHR。目前,当我发出请求时,它会无声地失败。我已经尝试使用jQuery jQuery.getJSON(url,callback)
和一个XHR对象。
var xmlhttp = new XMLHttpRequest();
//callback function when XMLHttpRequest is ready
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
if(xmlhttpForTGT.status==200){
response = xmlhttpForTGT.getResponseText()
}
else{
alert("Request Failed")
}
}
}
xmlhttp.open("GET", url , true)
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xmlhttp.send()
, and xui
x$('#home').xhr(url,
{method: 'get',
callback: function(){ alert('made request') }});
到目前为止,我还无法让它们中的任何一个工作。有其他人能够让xhr工作吗?我正在使用JRE4.6.1,并使用eclipse作为开发环境。当我尝试发出请求时没有抛出任何错误,请问有什么建议吗?