içinde [object% 20Object] ile eklenmiştir getJSON
yöntemini kullanarak jQuery ile yazdığım özel bir JSON beslemesi almaya çalışıyorum. Bilinmeyen bir nedenden ötürü, URL sonundan sıyrılan cache_gen.php?location=PL4
numarasına sahip görünüyor ve [object% 20Object] ile değiştiriliyor ve 404 hatası oluşuyor.JSON İstek jQuery
İşte kullanıyorum jQuery var:
var fetchData = function() {
if (Modernizr.localstorage) {
var api_location = "http://weatherapp.dev/cache_gen.php";
var user_location = "PL4";
var date = new Date();
console.log(api_location + '?location=' + user_location);
jQuery.getJSON({
type: "GET",
url: api_location + '?location=' + user_location,
dataType: "json",
success: function(jsonData) {
console.log(jsonData);
}
});
} else {
alert('Your browser is not yet supported. Please upgrade to either Google Chrome or Safari.');
}
}
fetchData();
konsol günlükten ben URL dizesi olarak doğru hesaplanır görebilirsiniz: konsolda ikinci çizgidir Ancak http://weatherapp.dev/cache_gen.php?location=PL4
: Failed to load resource: the server responded with a status of 404 (Not Found)
.
Bu yolla beni doğru yöne yönlendiren var mı? 19/01/2013 23:15
Eh, ben sadece o yüzden dönüştürdüğünüz
GÜNCELLEME mükemmel $.ajax
kullanarak dokümanları uyuyor. Ayrıca bir başarısızlık olayı ekledim ve iletilen tüm verileri kaydettim. Bu benim konsol şu bilgileri veriyor sonra
var fetchData = function() {
if (Modernizr.localstorage) {
var api_location = "http://weatherapp.dev/cache_gen.php";
var user_location = "PL4";
var date = new Date();
var url = api_location + '?location=' + user_location;
console.log(url);
jQuery.ajax({
type: "GET",
url: api_location + '?location=' + user_location,
dataType: "json",
success: function(jsonData) {
console.log(jsonData);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log('textStatus: ' + textStatus);
console.log('errorThrown: ' + errorThrown);
console.log('jqXHR' + jqXHR);
}
});
} else {
alert('Your browser is not yet supported. Please upgrade to either Google Chrome or Safari.');
}
}
fetchData();
: Ben JSON beslemesi için başlıkları güncel, ve yem kesinlikle geçerli JSON hizmet veren sağladık
http://weatherapp.dev/cache_gen.php?location=PL4
download_api.js:44textStatus: parsererror
download_api.js:45errorThrown: SyntaxError: JSON Parse error: Unable to parse JSON string
download_api.js:46jqXHR[object Object]
(etkili bir 3rd önbelleğe API'da maliyet tasarrufu için parti hizmeti feed'i). Gerçek işlev kullanım
http://weatherapp.dev/cache_gen.php?location=PL4 çalışan bir url değil.<----- tıklayın – Popnoodles
@popnoodles, bir '/ etc/hosts' yönlendirme olabilir :). Ama, kesinlikle '.dev 'balıkçıl – Alexander
.dev bir gelişim alanıdır. Bunu, yerel sistemimde bir Apache sanal-barındırıcısına sahip olarak ayarlamış bulunuyoruz. Bu, düzgün bir şekilde çözülmesini sağlamak için '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 'bir girişe sahiptir Bu alana tarayıcımda, JS dosyasının yüklenmekte olduğu alan adıyla erişebiliyorum. –