Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Learning AJAX
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #1
Learning AJAX
Do you have any recommended Ajax tutorials?
(This post was last modified: 02-14-2008 04:08 PM by blueparukia.)
02-04-2008 04:55 PM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Quick tutorial on making MyBB plugins
Google?

If you know Javascript, AJAX is easy (cause AJAX is Javascript Tongue).  Thus I'd start by looking into Javascript first.

My Blog
(This post was last modified: 02-04-2008 06:22 PM by ZiNgA BuRgA.)
02-04-2008 06:22 PM
Find all posts by this user
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #3
RE: Quick tutorial on making MyBB plugins
I know Javascript and PHP well, but I just can't get Ajax. I have tried the sites I normally learn from (w3schools and Tizag), but if I execute the example scripts one, then change the echo output in the php file, the result stays the same as the previous one.

But thats my problem. I vow to learn it one day Wink
02-04-2008 06:38 PM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Quick tutorial on making MyBB plugins
Umm, tried sending no cache headers, or clearing the cache?

My Blog
02-04-2008 06:52 PM
Find all posts by this user
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #5
RE: [split] Learning AJAX [previously: Quick tutorial on making MyBB plugins]
OK, clearing the cache works, but is highly annoying to do - and is only necessary on Opera. it works fine on IE7 and Firefox 2. Basically I want to click a button, and everytime the button is clicked, the exact time is shown, but in Opera you have to clear the cache EVERY time, so the time does not update.

Sending a no-cache header does work though - thanks a tonne Smile
(This post was last modified: 02-04-2008 08:15 PM by blueparukia.)
02-04-2008 08:10 PM
Find all posts by this user
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #6
RE: [split] Learning AJAX [previously: Quick tutorial on making MyBB plugins]
OK, so I have a few Ajax questions that Zinga will know Wink

1. Can you execute specific PHP functions?
Say all my PHP file contains is

PHP Code:
<?
function name(){echo "something";}
?>


Is it possible to specify (in the JS) to execute only that function?

2. Retrieving a value from an input

How do I do this in the PHP. Say I have

HTML Code
<input name="input" type="text">

  

How do I transfer that to the PHP form without submitting it? Via $_GET?.

That is all my incredibly inportant questions,

BP

02-05-2008 08:43 PM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #7
RE: [split] Learning AJAX [previously: Quick tutorial on making MyBB plugins]
Consider something like this:

HTML Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<form onsubmit="doAjaxSubmit(this);" method="post" action="...">
<input type="text" name="myvalue" />
<input type="submit" value="Go" />
</form>

<script language="javascript">
<!--
function doAjaxSubmit(fObj)
{
 var requestString = fObj.elements[0].name+'='+fObj.elements[0].value; // I _think_ that's correct...
 // I'm going to assume you're writing for MyBB, and using the moofx library
 new ajax("xmlhttp.php?action=my_custom_action", {method: "post", postBody: requestString, onComplete: function(request) { doAjaxComplete(request); }});
}

function doAjaxComplete(response)
{
 // handle stuff when AJAX request is complete here
}
//-->
</script>


PHP Code:
//...
if($mybb->input['action'] == 'my_custom_action') execute_my_custom_function();
//...


My Blog
(This post was last modified: 02-05-2008 10:22 PM by ZiNgA BuRgA.)
02-05-2008 10:21 PM
Find all posts by this user
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #8
RE: [split] Learning AJAX [previously: Quick tutorial on making MyBB plugins]
No, I am not coding for MyBB. Afaik I am not using any libraris, I am just codig straight into Notepad++...

Thanks for your help though.
02-06-2008 07:58 AM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #9
RE: [split] Learning AJAX [previously: Quick tutorial on making MyBB plugins]
^ Just use the moo.fx library - it's small and portable.

If you don't want to, you'll have to interface with xmlhttp request object yourself, and also handle various browser oddities...

Up to you.

My Blog
02-06-2008 01:04 PM
Find all posts by this user
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #10
RE: [split] Learning AJAX [previously: Quick tutorial on making MyBB plugins]
I'll look into it on Sunday. My grandparent just bought a new yacht. So we're going out to the reef for a few days Smile
02-07-2008 04:03 PM
Find all posts by this user

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: