Php 无法访问$.getJSON函数

Php 无法访问$.getJSON函数,php,javascript,jquery,json,Php,Javascript,Jquery,Json,下面是一段试图访问$.getJSON的代码,但它没有响应。可能的原因是什么 function getTerms() { alert("hello"); //it alerts hello $.getJSON('http://localhost/context-search.php?callback=?', function(r) { //not here

下面是一段试图访问$.getJSON的代码,但它没有响应。可能的原因是什么

        function getTerms()
        {
            alert("hello"); //it alerts hello           
            $.getJSON('http://localhost/context-search.php?callback=?', function(r) {
                //not here
                alert("Hello");
            });
        }
        $(document).ready(function(){
        alert("hello");         
        getTerms(); 
    });
context-search.php返回json数据,格式为

{“选项”:[“osi”、“tcp”、“ip”、“http协议”、“以太网”、“网络协议”、“协议含义\n”]}

我哪里可能出了问题??请帮我渡过难关!
谢谢!!:)

您是否检查了控制台日志? 如果它不包含错误,那么改为执行类似这样的json请求

$.ajax({
    url: url,
    dataType: 'json',
    data: data,
    success: function(){},
    error: function(jqXHR, textStatus, errorThrown) {
        console.log("error " + textStatus);
        console.log("incoming Text " + jqXHR.responseText);
    }
});
这将为您提供正确的错误处理。

可能是。假设这是在本地主机上运行的,您尝试过吗

$.getJSON('/context search.php?callback=?',…)

像这样使用

 $(document).ready(function(){
  $.getJSON('/ITTA/SavePreference/?t=' + new Date(), { id: id3 },
                   function (data) {
                       if (data != null && data != undefined && data != '') {
                           top.location.href = '/ITTA/Entries/' + id3;
                       }
                   }); });

@约瑟夫控制台没有输出任何东西。。它是空白的!!在使用ur函数时,表示数据未定义!!这是什么?