Michael,
Welcome to the list!

Your send function looks fine, except I have a few questions:

url: location.href is pointing to the current page, is this supposed to be
the case?

Since your dataType is json, you should not need to use "data =
eval(json);", if you are sending back your data, assuming you are using php,
but the same json structure will work in other languages, you should be able
to do the following:

from serverside:

echo '{somedata:"my data"}';

in javascript:
               success:function(json){
                   $('#commentdiv').html('' + json.somedata + '');
               }

Let me know if this make sense.

On 7/18/07, Michael <[EMAIL PROTECTED]> wrote:


im pretty new to jquery and im writing a ajax ready comment box for my
community site. Im very new to javascript but got into frameworks
reading about javascript along the way and i wanted to know if im
going about my send function in the right fashion?

        function send(){

        var conf = new Array();

        var posting      = $('#Post_Comment').html('loading..');



        conf['commenttext'] = $.trim($('#commenttext').val());

        conf['UserID']      = $('#ID').val()

        conf['MediaID']     = $('#MediaID').val();

        conf['WriterID']    = $('#WriterID').val();

        conf['comment_v']   = $('#true').val();





        if(conf['commenttext'] == '' || conf['commenttext'] == null){

        $('#Post_Comment').html('Post Comment');

        $('#status').html('<div align="center" class="YourInfo">Please
enter
some text</div>');

        setTimeout("$('#status').html('')",3000);

        return;

        }



        $.ajax({

        type: "POST",

        url: location.href,

        data: {

                "commentsubmit" : conf['comment_v'],

                "commenttext" : conf['commenttext'] ,

                "MediaID" : conf['MediaID'],

                "WriterID": conf['WriterID'],

                "ID" : conf['UserID']

                  },

        success: function(data){

        $('#Post_Comment').html('Post Comment');

    $.ajax({

                   type: "POST",

                   datatype: "json",

                   url: 'home/getcomments',

                   data: {

                             "ID" : conf['UserID'],

                                 "Type" : "Profile"

                                 },

                   success:function(json){
                   data = eval(json);

                   $('#commentdiv').html('' + data + '');

                   }

                   });



    }});



}




--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com

Reply via email to