java - Uncaught SyntaxError: Unexpected token < -
i using ajaxupload.js here , see file doing upload work alright. getting <pre style="word-wrap: break-word; white-space: pre-wrap;">{"id":"006","path":"006.png"}</pre> in response.
i think response should {"id":"006","path":"006.png"} reasons got wrapped around <pre> , hence uncaught syntaxerror: unexpected token <.
i using spring mvc 3, tomcat. using java.io.writer write response writer.write(json.tostring());
could me understand error , how resolve it?
thanks.
update:
code:
<form id="app-form" class="cols" action="#" method="post"> <fieldset class="w50"> <!-- set of form fields --> </fieldset> <fieldset class="w50"> <button id="uploadbutton" class="csbutton-grey" >upload</button> <ul id="locationimages"></ul> </fieldset> <div style="float: left;"> <button type="submit" class="cool-button">submit</button> </div> </form> $(document).ready(function(){ var button = $('#uploadbutton'), interval; new ajaxupload(button, { action: 'uploadimage', name: 'qqfile', responsetype: "json", onsubmit : function(file, ext){ this.disable(); console.log("file - " + file); console.log("ext - " + ext); if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ alert('error: invalid file extension'); return false; } else { $.ajax({ type:"get", url:"file", data:'file='+file, success:function(data, textstatus, jqxhr){ console.log(jqxhr.status); console.log(data); }, error:function(jqxhr, textstatus, errorthrown) { console.log(jqxhr.status); }, }); } }, oncomplete: function(file, response){ this.enable(); console.log("file - " + file); console.log("response.id - " + response.id + ", response.path - " + response.path); $('<li></li>').appendto('#locationimages').text(file); } }); });
have set responsetype property json in ajaxupload?
Comments
Post a Comment