ACTIVE SERVER PAGE > ajax Àü¼Û½Ã Çѱ۱úÁü (ANSI - ANSI °£¿¡ ÇѱÛÀü¼Û ¿¹Á¦)
µî·ÏÀÏ : 2017-07-04 18:27
Á¶È¸¼ö : 54,801
ANSI ¹®ÀÚ¼ÂÀ¸·Î µÈ »çÀÌÆ®¿¡¼ ajax Àü¼Û½Ã ÇѱÛÀÌ ±úÁö°Ô µË´Ï´Ù.
ÀÌ ¹®Á¦¸¦ ÇØ°áÇϱâ À§ÇÑ ¹æ¹ý ÀÔ´Ï´Ù.
1. escape , unescape »ç¿ëÇϱâ
ANSI ·Î ÀúÀåµÈ ASP ÆÄÀÏ
======== jquery Àü¼Û°ú °á°ú°ª ¹ÞÀ» ¶§ ====================
$.ajax({
type: "POST",
url: "/include/getServerData.asp",
data: "dataKind=leagueList&key1="+escape(sportNM),
success: function(rValue) {
alert(rValue);
}
});
ANSI·Î ÀúÀåµÈ ASP ÆÄÀÏ
========== ¼¹ö´Ü asp ÆÄÀÏ¿¡¼ Request ÇÒ ¶§ ==============
<%response.charset = "euc-kr"%>
key1 = unescape(Request("key1"))
Response.Write strTemp
Àü¼Û½Ã Çѱۺ¯¼ö¿¡ escape("ÇѱÛ") °ú °°Àº ÇüÅ·ΠÀÎÄÚµùÇØ ÁÖ¸é µË´Ï´Ù.
asp ¿¡¼ µ¥ÀÌÅ͸¦ ¹ÞÀ»¶§´Â unescape(Request("key1")) ·Î ¹Þ¾Æ ÁÖ¸é ³¡³µ´Ï´Ù.
2. utf-8 À» Áö¿øÇÏ´Â ÄÄÆ÷³ÍÆ® »ç¿ëÇϱâ
- utf-8À» Áö¿øÇÏ´Â ÄÄÆ÷³ÍÆ®¸¦ »ç¿ëÇؼ ³Ñ¾î¿Â °ªÀ» ¹Þ¾ÆÁÖ¸é ¾ÆÁÖ °£´ÜÈ÷ ÇØ°áÇÒ ¼ö ÀÖ´Ù.
- º»ÀÎÀÇ °æ¿ì ABCUpload ÄÄÆ÷³ÍÆ®¸¦ »ç¿ëÇÏ¿©¼ °£´ÜÈ÷ ó¸®ÇÑ´Ù.
- ÆäÀÌÁö »ó´Ü¿¡ jquery.form.js ÆÄÀÏÀ» ÀÎŬ·çµå ½ÃŲ´Ù.
-
test1.asp
function Upload() {
var options = {
beforeSubmit: function () {
if ($('#board_fname1').val() == "") {
alert("¾÷·ÎµåÇÒ ÆÄÀÏÀ» ¼±ÅÃÇØ ÁÖ¼¼¿ä!");
return false;
}
},
success: function (data) {
if (/(MSIE|Trident)/.test(navigator.userAgent)) {
// ie À϶§ input[type=file] init.
$("#board_fname1").replaceWith( $("#board_fname1").clone(true) );
} else {
// other browser À϶§ input[type=file] init.
$("#board_fname1").val("");
}
var status = data.status;
var fn1 = data.fn;
var goods_title = data.goods_title;
var goods_ment = data.goods_ment;
var tname = data.tname;
alert(status);
alert(fn1);
alert(tname);
}
},
error : function (jqXHR, exception) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status == 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
msg = 'Internal Server Error [500].';
} else if (exception === 'parsererror') {
msg = 'Requested JSON parse failed.';
} else if (exception === 'timeout') {
msg = 'Time out error.';
} else if (exception === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.\n' + jqXHR.responseText;
}
alert(msg);
},
url: "test_Upload.asp",
contentType: "multipart/form-data;charset=utf-8",
type: "post", /* get, post */
dataType: "json" /* xml, html, script, json */
};
$("#frm_board").ajaxSubmit(options);
}
form ID="frm_board" °ªÀ» submit ÇÏ´Â ¿¹Á¦ ÀÌ´Ù. ENCTYPE="MULTIPART/FORM-DATA" µ¥ÀÌÅÍŸÀÔÀ¸·Î Àü¼ÛÇÑ´Ù.
- ¾Æ·¡´Â test_Upload.asp ÆÄÀÏ ³»¿ëÀÌ´Ù.
- abcupload ÄÄÆ÷³ÍÆ®¿¡¼ °ªÀ» ¹ÞÀ» ¶§ UploadForm("tname")(1) °ú °°Àº ÇüÅ·Π¹ÞÀ¸¸é µÈ´Ù.
- ¹è¿ÇüÅ·ΠÀü¼ÛÀÌ µÇ¸é UploadForm("tname") ¿¡´Â ANSI °ªÀÌ UploadForm("tname")(1) ¿¡´Â UTF-8 °ªÀÌ Àü¼ÛµÇ´Â°É
È®ÀÎÇÒ ¼ö ÀÖÀ» °ÍÀÌ´Ù.
set FSO = Server.CreateObject("Scripting.FileSystemObject")
set UploadForm = Server.CreateObject("ABCUpload4.XForm")
'UploadForm.CodePage = 65001
UploadForm.Overwrite = True 'µ¤¾î¾²±â Çã¿ë
UploadForm.AbsolutePath = True
UploadForm.MaxUploadSize = 1024*1024*20 'ÆÄÀÏ¿ë·® (10M)
tname = WORD_CHANGE(UploadForm("tname")(1),100)
goods_title = WORD_CHANGE(UploadForm("goods_title")(1),100)
goods_ment = WORD_CHANGE(UploadForm("goods_ment")(1),100)
Response.Write "{""status"":""SUCCESS"",""fn"":""" & ok_filename & """,""tname"":""" & tname &""",""goods_title"":"""& goods_title &""",""goods_ment"":"""& goods_ment &"""}"
ÆÄÀϾ÷·Îµå ·ÎÁ÷Àº ºüÁ® ÀÖ´Ù.