Javascript Ajax表单提交-单击“更改html元素文本”时

Javascript Ajax表单提交-单击“更改html元素文本”时,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,所以我尝试创建一个消息系统。当我点击邮件打开时,我的模板会在同一页面中打开邮件内容。我试着这样做:“See”按钮->ajax->替换为jquery.text(“废话”)。问题是当我尝试 HTML代码: <form method="POST"> <button type="button" class="btn btn-small btn-success" name="msg_preview_id" value="'.$inbox_row['id']

所以我尝试创建一个消息系统。当我点击邮件打开时,我的模板会在同一页面中打开邮件内容。我试着这样做:“See”按钮->ajax->替换为jquery.text(“废话”)。问题是当我尝试

HTML代码:

<form method="POST">
                <button type="button" class="btn btn-small btn-success" name="msg_preview_id" value="'.$inbox_row['id'].'">New</button>
            </form>
PHP:


我在其他pge中使用$\u GET[]更简单

成功中的回调不在doneNothing中,仍然是相同的问题:/console.log(数据)的结果是什么?它是您期望的数据吗?是的,它来自表单的数据请显示您从php脚本返回的
json
-数据。
$(document).ready(function(){
$('button[name=msg_preview_id]').click(function(event) {

                var formData = {'msg_preview_id' : $('button[name=msg_preview_id]').val()};                


        $.ajax({
            type        : 'POST', // define the type of HTTP verb we want to use (POST for our form)
            url         : '../../class/messages/inbox_preview.php', // the url where we want to POST
            data        : formData, // our data object
            dataType    : 'json' // what type of data do we expect back from the server                        
        })

            .done(function(data) {                            

                console.log(data);                                                        

                                //Email Stuff
                                $('h1[id=emailheading]').text(""+data.info.subject+"");
                                $('a[id=emailfrom]').text(""+data.info.from+"");
                                $('span[id=emaildate]').text(""+data.info.rcvdat+"");
                                $('p[id=emailtext]').text(""+data.info.text+"");

                                //Ceninhas
                                $('#inbox-wrapper').addClass('animated fadeOut');
                $('#inbox-wrapper').hide();                 
                $('#preview-email-wrapper').addClass('animated fadeIn ');           
                $('#preview-email-wrapper').show();         
                //$('.page-title').show();  
                //Load email details
                $('#inbox-wrapper').removeClass('animated fadeOut');            
                $('#inbox-wrapper').removeClass('animated fadeIn');

            });                   

                        event.preventDefault();         
});
});
<?php

include ('../../inc/config.inc.php');

$data = array();
$info = array();

$Msg_Preview_ID = $_POST['msg_preview_id'];

$MsgSQL = mysqli_query($Connection, "SELECT * FROM messages_inbox WHERE id='$Msg_Preview_ID'");
$Msg = mysqli_fetch_assoc($MsgSQL);

$bzQuery = mysqli_query($Connection, "SELECT * FROM members_profile WHERE id='".$Msg['from']."'");
$bzFetch = mysqli_fetch_assoc($bzQuery);

$info['from'] = $bzFetch['fname']." ".$bzFetch['lname'];
$info['subject'] = $Msg['subject'];
$info['text'] = $Msg['text'];
$info['rcvdat'] = $Msg['rcvdat'];

$data['info']  = $info;

echo json_encode($data);