The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Need help with very simple AJAX...
I'm trying to figure this AJAX stuff out, but its SOOOOO confusing... Would someone mind helping me do this small script as SIMPLE as possible? Lets say I have the following code (psuedocode):
Code:
$value = SELECT char FROM mytable WHERE id = 1 Then in a table cell I have the following: Code:
<td><img src="$value[char].jpg"></td> Thanks in advance. |
#2
|
||||
|
||||
Sett up a ondblclick for that table by adding an internal div. Then set up your ajax function.
var ajax = ""; var url = "";// if using vbulletin templates add php code in the "" if(window.XMLHttpRequest()) { ajax = new XMLHttpRequest(); } else if(window.ActiveXObject) { ajax = new ActiveXObject("Microsoft.XMLHTTP") } ajax.open("GET", "your_script.php", true); if(ajax.readystate=4 && ajax.status=200) { ajax.send(null); } else if((ajax.readystate=1 && ajax.status=401 || ajax.readystate=2 && ajax.status=500)) { ajax.abort(); Theres your ajax functions right there now all thats left is to use javascript to create the new input form and trigger this function ondblclick so it sends for data, and replaces it into the value of the input box. Then re-trigger the ajax onsubmit so it updates the database and use ajax.responseText(); with innerhtml(); to save the changes to the value of the input box. |
#3
|
|||
|
|||
I would highly recommend looking into jQuery. It makes ajax so simple.
|
#4
|
|||
|
|||
Why use your own or jquery when vbulletin deliveres yui and his connection manager?
http://developer.yahoo.com/yui/connection/ |
#5
|
|||
|
|||
I don't like the YUI, I don't find it very developer friendly. But thats me.
|
#6
|
||||
|
||||
YUI3 is actually a lot more like jQuery now. Still beta, though.
+1 for jQuery. |
#7
|
||||
|
||||
However, since vBulletin itself is utilising YUI, it's probably better to stick with it for vBulletin modifications. Otherwise, I would agree with you.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|