用ajaxupload上传,需要返回修改后的图片名。ajaxupload里onComplete:的response输出全是jsp代码,
我怎么才能得到后台的response.getWriter().write(“XXXxxxxxxxxxxxxx”);onComplete: function(file, response){
  alert(response);
  。

解决方案 »

  1.   

    alert(response); 
    出来的是什么东西,看看你就知道了!
      

  2.   

    我已经输出了,全是jsp编译后的html代码。
    <thml>
      ................
    </thml>
      

  3.   

    我用Ajax前台接收的时候都是用 
    var res = XMLHttpReq.responseText;
    alert(res);
    直接用response我没试过,我感觉你在后台response.getWriter().write(“XXXxxxxxxxxxxxxx”); 
    是不是后面紧跟着return ..,所以才会出现html代码
    如果是的话,你把你就return null;
      

  4.   

    我return null了,
    结果还是 alert(res);
    <thml> 
      ................ 
    </thml>
      

  5.   

    你应该是在response.getWriter().write(“XXXxxxxxxxxxxxxx”); 之后紧跟着return。PrintWriter out=response.getWriter();
    if (b) {
    out.println(0);
    } else {
    out.println(1);
    }
    return null;这样写就不会出现html代码。
    如果你把return写在判断语句里面,返回的就是html。
      

  6.   

    楼上这位兄弟:你写的我试了,
    response.getWriter().println("{picPath:true,message:'0'}");
    return null;
    还是<thml>   ................ </thml>
    ----------------------------------------------
      responseType: false,//'json', 这两个应该是哪个?
      我现在是false。
      如果用'json',
    ajaxupload.js里
      alert(doc.body.firstChild.nodeName)=‘form’
    然后到response = window["eval"]("(" + response + ")");就出脚本错误了。
    下面是代码:
    if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE'){
    response = doc.body.firstChild.firstChild.nodeValue;
    }
    //alert(response);
    if (response) {
    response = window["eval"]("(" + response + ")");
    } else {
    response = {};
    }
      

  7.   

    说真的,你写的,我看的都不是很明白,这样吧,你加我qq,我们讨论一下吧。
    response.getWriter().println("{picPath:true,message:'0'}"); 
    return null; 
    这个return null; 不能紧跟在response.getWriter().println("{picPath:true,message:'0'}");
    我也是新手,47374588。