IMG
jQuery と AJAX を使用してフォームを送信すると、返された HTML でタグを含む 403 エラーが発生します。
フォームを送信するために使用しているコードは次のとおりです。
// Add a new personality to the quiz
$('form#personality_editor').submit(function(e) {
e.preventDefault();
// Submit the form with jQuery Form plugin to handle attachments
$(this).ajaxSubmit({
dataType: "json",
resetForm: true,
beforeSend: function() {
// Show the loading spinner
$('img#personality_loader').show();
},
success: function(add_personality_response) {
// Hide the image loader
$('img#personality_loader').hide('fast');
if (add_personality_response["success"] == "true") {
// Create a new personality in the list of personalities
$('div#quiz_personalities').append(add_personality_response["personality_html"]);
// Add the personality to list of hidden personalities
AddRemovePersonality(add_personality_response["personality_id"], "add");
// Set the focus on to personality name
$('input#new_personality_name').focus();
// Show or hide the no personalities notice
ShowHideNoPersonalitiesNotice();
alert("Success");
}
},
error: function() {
alert("There was an error adding personality");
}
});
});
コードから返される完全な JSON 応答は次のとおりです。
{"success":"true","personality_id":191,"personality_name":"Avril Lavigne","personality_image":"191avril.jpg","personality_html":"<div class=\"personality_wrapper\" data-personality-id=\"191\"><img src=\"images\/personalities\/personality_images\/192avril.jpg\" class=\"personality_image_small\" \/><div class=\"personality_info\"><div class=\"personality_name\" title=\"Kjh\">Kjh<\/div><div class=\"personality_options\"><a href=\"#\" class=\"personality_option personality_edit\">Edit<\/a><a href=\"#\" class=\"personality_option personality_delete\">Delete<\/a><\/div><\/div><\/div>"}
jQuerypersonality_html
の機能を使ってDOMに追加しているのは です。.append()
この問題は Chrome で動作しているため、Internet Explorer で発生しています。
画像は、私のサーバーの場所に正常にアップロードされていますimages/personalities/personality_images/192avril.jpg
。
ページから返される応答は次のとおりです。
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /"images//personalities//personality_images//192avril.jpg/"
on this server.</p>
</body></html>
私のページから渡されたエスケープされたデータと関係がありますか? 応答するjson_encode()
前に使用しています。echo
IE の開発者ツールからのビューは次のとおりです。