Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Learning AJAX
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

« Next Oldest | Next Newest »

Messages In This Thread
Learning AJAX - blueparukia - 02-04-2008, 04:55 PM
RE: [split] Learning AJAX [previously: Quick tutorial on making MyBB plugins] - ZiNgA BuRgA - 02-05-2008 10:21 PM

 Standard Tools
Forum Jump: