0
我已閱讀並應用了一些類似的解決方案,但到目前爲止效果不佳。ajaxForm:如何擺脫'<pre>' and '</pre>'的迴應?
HTML
<form id="update-form" action="/update" enctype="multipart/form-data" method="post">
<input type="file" name="file" single />
<input type="submit" value="submit />
</form>
<script>
$(function() {
$('#update-form').ajaxForm({
success: function(data) {
alert(data);
}
});
});
</script>
西納特拉
post '/update' do
...
content_type :json
{ :success => true }.to_json
end
當我運行它,之後點擊 「提交」,我收到警告:
<pre>{"success":true}</pre>
這個 「預」 的事情是真的惱人的,這阻止了parseJSON的正確調用。我可以做一些字符串操作來刪除它。但我想有更好的解決方案。
感謝您的幫助。
來吧,沒有答案呢?! – user180574