Форум SAPE.RU

Форум SAPE.RU (http://forum.sape.ru/index.php)
-   Разработка и сопровождение сайтов (http://forum.sape.ru/forumdisplay.php?f=29)
-   -   Помогите с AJAX (http://forum.sape.ru/showthread.php?t=29866)

avgaz 11.04.2009 21:49

Помогите с AJAX
 
Имеется такой js код который должен отправить данные из формы
Код:

function instchatSave() {
        //MK_Spinner = new MKSpinner();
        mkportal_Spinner_Show();
        var url =  MKAJAX_SITEPATH + 'index.php?ind=urlobox&op=ajax_savemsg';
        message =document.getElementById('ta').value;
        if(message == "")
        {
            return false;
        }
        postData = "value="+encodeURIComponent(message).replace(/\+/g, "%2B");
      new MKP_ajax(url, {method: 'post', postBody: postData, onComplete: function(request) { instchatSaveComplete(request); }});
    }

function instchatSaveComplete(request) {
       
        if(request.responseText.match(/<error>(.*)<\/error>/)) {
            message = request.responseText.match(/<error>(.*)<\/error>/);
            if(!message[1]) {
                message[1] = "An unknown error occurred.";
            }
            alert("There was an error performing the update."+message[1]);
        }
        else if(request.responseText)
        {
            document.getElementById('instchat_2').innerHTML = request.responseText;
            document.getElementById('ta').value = "";
        }
        mkportal_Spinner_Hide();
}

function instblockSubmit() {
        instchatSave();
        Switch_InstEd();
        return false;
}

сама форма
Код:

<form id="editor" name="editor" style="padding: 0px;" method="post" onsubmit="return instblockSubmit();">

                <centr>
            <input type="text" id="ta" name="ta" style="width: 98%; border:0; padding: 4px; margin: 0;  background-color: #FFF;">                       
                      </center>
                          </form>
                </td>
                <td id="instchatcontent" name="instchatcontent" style="width: 100%; padding:0px; border-bottom: 1px solid; background-color: #F5F5F5;">
                <div id="instchat_2" style="padding:4px; background-color: #F5F5F5; color: #333; font-size: 10px;">
       
                <br /></div

в каком виде ложны придти данные в файл совсем замучался не как понять не могу
Код:

$message .= $_POST['postData'];
        $message .= $_POST['ta'];
        $message .= $_POST['message'];
          $message .= $_POST['postBody'];
          $message .= $_POST['instchatSaveComplete'];
          echo  $message;

не чего не выводит

ahsinis 12.04.2009 08:26

Цитата:

new MKP_ajax(url, {method: 'post', postBody: postData, onComplete: function(request) { instchatSaveComplete(request); }});
Тут в параметрах не надо передать заголовок?
Код:

Content-Type: application/x-www-form-urlencoded
без фреймворков это выглядит как
Код:

loader.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");


Часовой пояс GMT +3, время: 16:46.

Работает на vBulletin® версия 3.8.7.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot
SAPE.RU — система купли-продажи ссылок с главных и внутренних страниц сайтов.