MyBB Community Forums

Full Version: Put data into a variable using a plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(2014-04-08, 03:14 AM)Omar G. Wrote: [ -> ]
new Ajax.Request('./xmlhttp.php?action=sixpackdharmiee', {method: 'post', postBody: shout, onComplete:function sixpackdharmiee(request)
{
	if(error = request.responseText.match(/<error>(.*)<\/error>/))
	{
		alert("An error occurred when rating the post.\n\n" + error[1]);
		return false;
	}

	content = request.responseText.split('|-_-|');
	if(content[0] != 'success')
	{
		alert('An error occurred when rating the post.');
		return false;
	}

	alert('Ok, sixPackDharmiee, check yo DB :)');
	return true;
}});
return false;

Hope this does helps, JavaSciprt and AJAX is not on my skills :p

Ahh me too! Though I already finished the javascript part, the part I'm stuck on is retrieving data in PHP so i can process it to Database.

Thank you!
I'm not sure what you mean. Do you mean this by chance?

$plugins->add_hook('xmlhttp', 'foo');
function foo()
{
	global $mybb;

	if($mybb->input['action'] == 'sixpackdharmiee')
	{
		return false;
	}

	$id = (int)$mybb->input['id'];
	$name = (string)$mybb->input['name'];

	if($id < 1)
	{
		error('Invalid ID.');
	}

	echo $name;
	return true;
}
Pages: 1 2