weixin_33674437 2017-03-26 18:03 采纳率: 0%
浏览 41

用Ajax发布div的文本

I want to post the content of div(text) to a php page with ajax, i have already this script which post all the input fields of the three forms

.on('actionclicked.fu.wizard' , function(e, info){
    if(info.step == 3 ) {
        var dataString = $("#form1, #form2, #form3").serialize();
        var mydiv = $('#mydiv').html();
        $.ajax({
            data: dataString + mydiv,
            type: 'POST',
            url: 'confirmation.php',
            cache: false,
            success: function(data) {
                message : 'you request was submitted'
            }
        });               
    }
})

but i need to post also the text of the div in the php page i use $mydiv =$_REQUEST['mydiv']; I can echo all the other fields but nothing return for $mydiv.

  • 写回答

2条回答 默认 最新

  • weixin_33713350 2017-03-26 18:12
    关注
    `.on('actionclicked.fu.wizard' , function(e, info){
            if(info.step == 3 ) {
               var a = $("#form1").serialize();
               var b = $("#form2").serialize();
               var c = $("#form3").serialize();
               var d = $(#mydiv).text();
               data = {};
               data['astring'] = a;
               data['bstring'] = b;
               data['cstring'] = c;
               data['ddivtext'] = d;
               $.ajax({
                   data: data,
                   type: 'POST',
                   dataType: "json",
                   url: 'confirmation.php',
                   cache: false,
                   success: function(data) {
                       message : 'you request was submitted'
                   }
               });               
            }
        })
    
    评论

报告相同问题?