Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6932843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:45:25+00:00 2026-05-27T11:45:25+00:00

<div id = ‘eventcontainer’ > <span id = ‘class’> <?php //Getting posts from DB

  • 0
<div id = 'eventcontainer' >
<span id = 'class'>
<?php

//Getting posts from DB

$event1 = mysql_query("SELECT post,date,memid FROM postaction WHERE memid = '$id' ORDER           BY date DESC LIMIT 5;");

while ($row1 = mysql_fetch_array($event1))
{

$event = $row1['post'];
$timeposted = $row1['date'];

$eventmemdata = mysql_query("SELECT id,firstname FROM users WHERE id = '$id' LIMIT 1");

while($rowaa = mysql_fetch_array($eventmemdata))
{
$name = $rowaa['firstname'];
 $eventlist = "$event <br> $name";
}


echo " <div id = 'eventer'> $timeposted <br>$eventlist</div> <input name='myBtn'            type='submit' value='increment' onClick='javascript:ajax_post();'>
<input name='lol' type='submit' value='dec' onClick='javascript:ajax_posta();'>
<div id = 'status'>lol</div>";
echo "<br>";

}
$('.eventcontainer.button').click(function() { 
$.post('javas.php', function(data) {
   $(this).parent('div').find('.status').html(data);
})
});
?>
</div>
</span>

I get an error when trying to run this code.
What i am trying to do is try to read which div/class the button is being clicked in, then perform the relative ajax/jquery functionality in that class only.

This is the Ajax/Jquery
function ajax_post(){

  $('.eventcontainer.button').click(function() { 
$.post('javas.php', function(data) {
   $(this).parent('div').find('.status').html(data);
})
});


hr.open("POST", url, true);

// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
    if(hr.readyState == 4 && hr.status == 200) {
        var return_data = hr.responseText;
        document.getElementById("status").innerHTML = return_data;
    }
}
// Send the data to PHP now... and wait for response to update the status div
hr.send("num=" + (++num)); // Actually execute the request
document.getElementById("status").innerHTML = "processing...";

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:45:26+00:00Added an answer on May 27, 2026 at 11:45 am

    As the comments have noted, you should not have jQuery in your PHP tags. Add some script script tags to your page’s head, add a document.ready handler, then put the script in there.

    Just note that once you accomplish this, you’ll still have some problems since you’re getting your this values mixed up.

    $('.eventcontainer.button').click(function() { 
       $.post('javas.php', function(data) {
          $(this).parent('div').find('.status').html(data); 
       })
    });
    

    Once you hit the callback of your $.post call, this no longer is equal to the item you clicked on. You’ll need to save that element in a local variable before the call to post.

    Something like

    $('.eventcontainer.button').click(function() { 
        var self = this;
        $.post('javas.php', function(data) {
          $(self).parent('div').find('.status').html(data);
       })
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Each div with the class row is added upon request from the user, to
$(div.date) .contents() .filter( function(){ return this.nodeType != 1; }) .wrap(<span/>); I am new and
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
struct Div { int i; int j; }; class A { public: A(); Div&
div is a block element and span is an inline element so according to
My div with class name 'header-body-right' doesn't seem to be floating to the left
$(div.test).mouseenter(function() { $(div.innerDiv).fadeIn(slow); }).mouseleave(function() { $(div.innerDiv).fadeOut(slow); }); <div class=test> <div class=innerDiv>1</div> </div> <div class=test>
%div{:class => [@item.type, @item == @sortcol && [:sort, @sortdir]] } Contents could render as
div ><hr><p><span STYLE=font-size:24; color: black>Site:</span> Downtown Denver DataCenter - CCODEN44 | <span STYLE=font-size:24; color:
%div{:id=>[Arsenal[@home.page_color]], :class=> page} I'm using the following constant Arsenal in my Home#Page view. Where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.