vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Need help with very simple AJAX... (https://vborg.vbsupport.ru/showthread.php?t=219161)

Jaxel 07-22-2009 09:44 AM

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
This code returns $value[char] as "amy".

Then in a table cell I have the following:
Code:

<td><img src="$value[char].jpg"></td>
I want to be able to double click anywhere on that table cell, and get a text box that lets me edit the value of char FROM mytable WHERE id = 1. Pretty much the same thing as the inline title editing on vBulletin, except that it shows the text value as an image when its done.

Thanks in advance.

pein87 07-23-2009 02:14 PM

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.

1Unreal 07-23-2009 02:31 PM

I would highly recommend looking into jQuery. It makes ajax so simple.

ragtek 07-23-2009 02:41 PM

Why use your own or jquery when vbulletin deliveres yui and his connection manager?
http://developer.yahoo.com/yui/connection/

1Unreal 07-23-2009 02:52 PM

I don't like the YUI, I don't find it very developer friendly. But thats me.

Adrian Schneider 07-23-2009 05:19 PM

YUI3 is actually a lot more like jQuery now. Still beta, though.

+1 for jQuery.

Dismounted 07-24-2009 09:34 AM

Quote:

Originally Posted by 1Unreal (Post 1854239)
I don't like the YUI, I don't find it very developer friendly. But thats me.

However, since vBulletin itself is utilising YUI, it's probably better to stick with it for vBulletin modifications. Otherwise, I would agree with you.


All times are GMT. The time now is 07:59 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01941 seconds
  • Memory Usage 1,730KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete