2010-01-28 jQuery.upload
jQuery.upload
<script type="text/javascript"> $(function() { $('#upload_button').click(function() { $('#fields').upload('/jquery/upload/demo_upload.json', function(res) { alert( 'Field1: ' + res.field1 + "\n" + 'Field2: ' + res.field2 + "\n" + 'Filename: ' + (res.file ? res.file.name : '') ); }, 'json'); }); }); </script>
<form action="#" method="post"> <div id="fields"> <label>Field1</label><input name="field1" value="" type="text"><br> <label>Field2</label><input name="field2" value="" type="text"><br> <input name="file" type="file"><br> </div> <input value="Submit" id="upload_button" type="button"> </form>
エラーが出た
Firefoxではjsonを表示すると勝手に<pre></pre>が入り、IEではダウンロードになる
解決
ImportAction.java
public ActionResult index() throws IOException {
JsonProvider jsonProvider = ProviderFactory.get(JsonProvider.class);
try {
userService.importUsers(csv);
} catch (Exception e) {
json = jsonProvider.toJson(getErrorJsonMap(e));
return new Forward("../json.jsp");
}
json = jsonProvider.toJson(getSuccessJsonMap());
return new Forward("../json.jsp");
}
<body> <pre>${action.json}</pre> </body>
96行目を修正 data = $(contents).find('body').find('pre').html(); ↓ data = $(contents).find('body').html();
コメントを書く
トラックバック - http://d.hatena.ne.jp/hayashi_77/20100128/1264670234
リンク元
- 9 http://twitter.com/hayashi_77
- 3 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&hs=D7l&num=50&q=hashmap+クラス ジェネリクス&btnG=検索&lr=&aq=f&oq=
- 3 http://www.google.co.jp/search?hl=ja&source=hp&q=app.diconが見つかりません&btnG=Google+検索&lr=&aq=1&oq=app.dic
- 2 http://hootsuite.com/dashboard
- 2 http://www.google.co.jp/search?hl=ja&q="org.seasar.framework.exception.ResourceNotFoundRuntimeException:+[ESSR0055]リソース(app.dicon)が見つかりません"&lr=la
- 2 http://www.google.co.jp/search?hl=ja&source=hp&q=致命的:+サーブレット+default+のServlet.service()が例外を投げました&
- 1 http://74.125.153.132/search?q=cache:DqWXmqS5qdQJ:d.hatena.ne.jp/hayashi_77/20090930/1254314763+IORuntimeException&cd=9&hl=ja&ct=clnk&gl=jp&lr=lang_ja&client=firefox
- 1 http://74.125.153.132/search?q=cache:J93CjmloY_MJ:d.hatena.ne.jp/hayashi_77/20091104/1257318827+s2dao app.dicon DAO&cd=4&hl=ja&ct=clnk&gl=jp&client=firefox-a
- 1 http://d.hatena.ne.jp/notify-Notify_NG_site?aHR0cDovL2QuaGF0ZW5hLm5lLmpwL2hheWFzaGlfNzcvMjAwOTExMDkvMTI1Nzc0NTk3MA==
- 1 http://friendfeed.com/hayashi777/b10d0479/jquery
