miracle_potential Posted July 14, 2008 Share Posted July 14, 2008 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 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 Quote Link to comment Share on other sites More sharing options...
FlyingIsFun1217 Posted July 15, 2008 Share Posted July 15, 2008 Check out w3schools' AJAX tutorial(s). And the first thing I noticed by glancing through the script, is that you never define what 'http' is. Looking through the tutorial I linked to will show you the basic setup of an ajax app FlyingIsFun1217 Quote Link to comment Share on other sites More sharing options...
corbin Posted July 15, 2008 Share Posted July 15, 2008 Wow seems like I managed to reply to the wrong thread earlier... http://www.phpfreaks.com/forums/index.php/topic,206137.msg938757.html#msg938757 Anyway, I must agree with FlyingIsFun1217. Hopefully an example script will help you grasp the basics, but you really should learn it from the ground up. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.