转换为发布到PHP的AJAX中的表单数据语言

时间:2015-05-21 21:57:34

标签: javascript php jquery ajax

我不使用Javascript,但我将其用作我网站的工具。

我创建一个带有文本输入的表单,当我写阿拉伯语时,它给我这样的

  

%u0645%u062D%u0645%u062F

我将meta charset设置为utf-8

我尝试制作许多解决方案,但没有发生任何事情

<!doctype html>
<html lang="ar">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>serializeArray demo</title>
    <script src="jquery-2.1.3.min.js" type="text/javascript"></script>
</head>

<body>
    <?php print_r($_REQUEST); ?>
    <p><b>Results:</b> <span id="results"></span></p>
    <form method="POST" enctype="multipart/form-data" id="POD">
        <input type="hidden" value="https://localhost/form.php" name="req">
        <input type="text" name="ogs" value="">
        <input class="btn btn-primary" name="ADD" id="add" value="ADD" onclick="AjaxPost('POD');" type="button">
    </form>
    <script>
        function AjaxPost(rowid) {
                var formData = new FormData();
                var strSubmitContent = '';
                document.getElementById(rowid).className = "submit";
                var url = document.forms[rowid].req.value;
                var strSubmitContent = '';
                var formElem;
                var strLastElemName = '';
                var docForm = document.forms[rowid];
                for (i = 0; i < docForm.elements.length; i++) {
                    formElem = docForm.elements[i];
                    switch (formElem.type) {
                        case 'hidden':
                            formData.append(formElem.name, escape(formElem.value));
                            break;
                        case 'text':
                            formData.append(formElem.name, escape(formElem.value));
                            break;
                            $("#results").empty();
                            $.ajax({
                                url: url,
                                type: 'POST',
                                data: formData,
                                async: false,
                                success: function(data) {
                                    var res = "<div class=\"alert alert-success\" role=\"alert\"><br />" + data + "</div>";
                                    $("#results").append(res + " ");
                                },
                                cache: false,
                                contentType: false,
                                processData: false
                            });
                    }
    </script>
</body>

</html>

0 个答案:

没有答案