Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Logic and Machanics of a conversation system

    Hello and welcome! We've fallen into a dark black abyss of "Don't know how" and we need help! We are trying to create post and deletion functionality for a grand conversation system using jquery and php and there is much we have to learn.

    This is what we have so far:

    Summary:trying to impliment a deletion form within queried user posts. The form in each post carries two hidden input tags with the deletion id for ajax
    and the div's id that will be hidden/removed on the clicking of the deletion button.

    My Questions:

    all the deletion forms have the same class embedded in the delete button.Will the wrong value be fetched when using jquery selector
    $('#'+ id).val() ??? If so how do remove the div onclick?

    how do I retrieve and access the data sent through ajax?

    $('.delete').on(click,function(){


    //hide div fadeout
    var id= $('#post_id').val(); //the value of hidden form element
    ('#'+id).fadeOut(fast,function() { $(this).remove(); });

    var delete=$('#delete_id').val();

    $.ajax({

    type:"POST",
    url:"delete_post.php",
    data:"delete_id=" + delete,
    success:function(){


    }

    });

    });



    $('#submit_post').on(click,function(){


    //capture text val
    //add text to variable with post div format
    //append to #reply unorderd list
    send to ajax to store in db

    });
    ---------------------------------- php code ---------------------------------------------
    while($initial= mysql_fetch_assoc($query_initial)){

    $post_id= $initial['post_id'];
    $post_date= $initial['post_date'];
    $text= $initial['text'];
    $poster_id= $initial['member_id'];
    $poster_name= $initial['poster_name'];
    $image=$initial['member_image'];
    $image_size= $initial['size'];
    $image_type= $initial['mime_type'];
    $divid="div".$poster_id;

    if($_SESSION['breadder_id'] == $post_id){
    $interaction= '<form name="post_form" ><input type="hidden" name="post_id" id="post_id" value="$divid"/><input type="hidden" name="delete_id" id="delete_id" value="$post_id"/><input type="submit" class="delete" value="delete"/></form>

    }
    else{


    $interaction= '<a href="#" id="reply"><span style="color:red;"><button>Reply</button></span></a>';
    }



    header("Content-type:$image_type");
    header("Content-length:$image_size");

    echo"---------------post here--------------"

  • #2
    Regular Coder Redcoder's Avatar
    Join Date
    May 2012
    Location
    /dev/null
    Posts
    333
    Thanks
    2
    Thanked 47 Times in 46 Posts
    try grouping the code and puting it inside tags or tags. It really helps its readability.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •