我想通过jQuery Ajax调用来从 data.php
数据。
I'm trying to get data from data.php
via jQuery ajax call.
我的code是这样的:
My code looks like this:
var jsonData;
$.ajax({
url: 'data.php',
success: function(response) {
jsonData = response;
}
});
我的 data.php
文件返回JSON格式的数据,但一些文字是统一code格式。
我设置 data.php
和我的JavaScript文件的字符集,但仍然无法访问responced数据对象。
My data.php
file is returning json formatted data but some text is in Unicode format.
I set charset on data.php
and on my javascript file, but still cant access responced data objects.
任何想法?
尝试把数据类型:JSON
在你AJAX调用:
Try to put dataType: 'json'
in you ajax call:
var jsonData;
$.ajax({
url: 'data.php',
dataType: 'json',
success: function(response) {
jsonData = response;
}
});