当前位置: 代码迷 >> Ajax >> Jquery getJSON求教解决思路
  详细解决方案

Jquery getJSON求教解决思路

热度:288   发布时间:2013-04-26 16:27:53.0
Jquery getJSON求教
        var onCommandChange = function() {
            var data = {id: $('select.cmdtype-list option:selected').val()};
            alert(getRootPath() + '/task/getCommand');
            $.getJSON(getRootPath() + '/task/getCommand', data,  function(json){
                alert("err");
                $("textarea#cmd_prj").text(json.text);
            })
        }


以上代码 怎么走不到task 的 actionGetCommand 里去? 有第一个alert,无 actionGetCommand函数入口的打印信息 。
jQuery JavaScript getJSON

------解决方案--------------------
alert(getRootPath() + '/task/getCommand');


浏览器直接访问这个地址看输出什么。。感觉就是你路径没对,java不清楚,有些方法是区分大小写的
------解决方案--------------------
var onCommandChange = function() {
            var data = {id: $('select.cmdtype-list option:selected').val()};
            alert(getRootPath() + '/task/getCommand');
$.ajax({url:getRootPath() + '/task/getCommand',data:data
,dataType:'json'
,success:function(){alert("err");$("textarea#cmd_prj").text(json.text);}
,error:function(xhr){alert('错误\n\n'+xhr.responseText)}
})
          
        }


改$.ajax看发生什么错误,可能是报错了
  相关解决方案