Jump to content

Div posting to Ajax


Recommended Posts

OK, I've left the login thing for now haha

 

I need to work something out for the products section as you probably saw I was having issues with loops last time. Fixed that  :)

But I just need to know the best way to do this. And if this will even work 0.o

 

<script type="text/javascript" language="javascript">
<!--

function change(catagory, paction, ID) {

document.getElementById('productsDIV').innerHTML = "<img src='images/loading.gif' alt='Loading Please Be Patient' />"

//cant work out how to set the variables for this

http.open('POST', 'testhelp.php?paction='+paction+'&catagory='+catagory);
http.onreadystatechange = ajaxction;
http.send(null);
}

function ajaxction() {
if(http.readyState == 4){ 
var newcontent = http.responseText;
document.getElementById('productsDIV').innerHTML = 'There Was An Error :[';
}
else{
document.getElementById('productsDIV').innerHTML = ''+newcontent+'';
}
//-->
</script>

 

On the page will be a container div which will have LOTS of little divs inside it might make it a table either way! and I cant work out how I'd get an onclick function on the divs to send a variable to the Ajax and reload the page according to what "link" was pressed.

 

Not even sure if this is going to work I'm a total newbie with Ajax usually just use Iframes but Ajax will look better on the ol' CV  :P

 

and just so you know there are multiple functions in my PHP class controlled with a switch so I need someway of getting the accoriding next action along with whatever catagory is clicked (the section I'm on). But for now just getting a div to post to Ajax will help me loads I can work stuff out from there.

 

<3 Google hehe  :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.