1. I've started a massive SPAM purge, any accounts that have spammed are being removed, also for a short period new user signups are disallowed until the SPAM cleaning is finished.

how to handle array of value in ajax()

Discussion in 'Java Script/AJAX' started by msankar, Jun 29, 2013.

  1. msankar

    msankar New Member

    Joined:
    Jun 22, 2013
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Location:
    India
    I want to call one query.php file using ajax(). The query.php file return array of data so i have doubt
    how to get array of values while return it.
    PHP:
    $catid=$_POST['cat_id'];
    $sql=mysql_query("select image_id,title,des,imagename from image_table where catagory_id=".$catid);
    $row=mysql_fetch_assoc($sql);
    echo $imgid=$row['image_id'];
    $tagquery=mysql_query("select tag from tag_table where catagory_id=".$imgid);
    echo $result=mysql_fetch_assoc($tagquery);
    HTML:
    $.ajax({
                        type: "POST",
                        url: "query.php",
                        data:{cat_id:catid},
                        dataType: 'json',
                        success: function(data) {
                                              alert(data.cat_id+"Inserted");
                                            }
                      });
                  return false;
    i expect this kind of output
    var imagename=data[];
    var imagetitle=data[];
    var imagedes=data[];

    so how to handle this sutiation. share your ideas and suggestions.
    Loading...

Share This Page