我有這個基本上提出請求的一小段代碼,並在console.log
(我省略了我的密鑰和sig)拋出結果。jQuery的Ajax請求 - 似乎沒有提出請求
問題是,它似乎從來沒有提出要求。
感謝您的幫助,我是一個新手,我還在學習。
//alert('you clicked on the discgolf button');
$('#zipsubmit').click(function(){
dgZipSearch(); // call this function perform DGCR search and
populate the page with results
});
function dgZipSearch(){
alert('foo1');
$.ajax({
url:'http://www.dgcr-api.com/?key=xxxxx&mode=findzip&zip=' + $('#zipcode').val() + '&rad=10&sig=yyyyyyy',
dataType: 'jsonp',
success: function(zip_results){
console.log(zip_results);
}
});
alert('foo2');
};
你確定這真的是JSONP嗎?你在控制檯中看到什麼? – SLaks
你有沒有試過把'error'回調加入你的代碼?也許它會給你一些線索,爲什麼這不起作用。另外,如果您實際上遇到錯誤,請記住使用'statusCode'檢查http代碼。 – MilkyWayJoe
你有沒有在頭腦中包含jquery? – doniyor