Ajax button you say? With php?
Prototype to the rescue!
Generate this line in your php script, adding the variableN with the
stuff you want to send as a http post to your ajax backend php script.
<div id=”ajaxview”> <a href=”javascript: void(0)” onclick=”manageajax(’variable1′,’variable2′,’variable3′) “;> link or image</a></div>
The magic you have to put in your .js file is like this:
function manageajax(param1,param2,param3) {
var url = ‘manageajax.php’;
var params = ‘param1=’ + param1+ ‘¶m2=’ + param2+ ‘¶m3=’ + param3;
var
ajax = new Ajax.Updater(
{success: ‘ajaxview’},
url,
{method: ‘get’,parameters: params,onFailure: reportError});
}
this bit you need too:
function reportError(request) {
$F(’photoResult’) = “An error occurred”;
}
manageajax.php is your backend, generate the HTML you want replace in div id=”ajaxview”.
When ppl click the link or button in your first line, it sends the variables you generated to the backend, and then replace the div content with the output from the backend. Make sure the backend works, you get no error feedback.
Good luck!










