Lawrence
Lawrence

Reputation: 727

Jquery passing data via .load

I'm not sure why i can' t get my output to surface. It shouldn't be too hard but has been stuck for several hours. All i

<script>
$(document).ready(function(){
    $('#chat_submit').click(function(){
        var data="{'chat_content:'+$('#chat_content').val()+'chat_from_who:'+$('#chat_from_who').val()+'chat_to_who:'+$('#chat_from_who').val()+'order_no:'+$('#order_no').val()}";
        $('#order_chatbox').load('/seller/helpers/order_chat.php',data);
    });
});
</script>

Any help here will be greatly appreciated.

Upvotes: 1

Views: 79

Answers (2)

Ram
Ram

Reputation: 144689

Try the following:

$(document).ready(function() {
    $('#chat_submit').click(function(event) {
        // event.preventDefault();
        var data = {
            chat_content: $('#chat_content').val(),
            chat_from_who: $('#chat_from_who').val(),
            chat_to_who: $('#chat_from_who').val(),
            order_no: $('#order_no').val()
        };
        $('#order_chatbox').load('/seller/helpers/order_chat.php', data);
    });
});​

Upvotes: 1

Gabriele Petrioli
Gabriele Petrioli

Reputation: 196002

You are sending the data as a long string.. not as an object.

Change it to

var data= {'chat_content': $('#chat_content').val(),
    'chat_from_who': $('#chat_from_who').val(),
    'chat_to_who': $('#chat_from_who').val(),
    'order_no': $('#order_no').val()};

Upvotes: 2

Related Questions