Not much knowledge about Javcascript beyond using it for some Dynamic HTML. Now I'm venturing a bit into Ajax ground and have a problem with the following code (borrowed from http://kpumuk.info/php/ajax-enabled-smarty-plugins-part-2-ajax_form/ and edited to fit my needs).
How can I pass the update_id parameter to the obSubmit function?
var SmartyAjax = {
submit: function(form, update_id, params, callback)
{
var myAjax = new Ajax.Request(
form.action,
{
method: form.method,
parameters: Form.serialize(form.id),
onComplete: callback || this.onSubmit
});
},
onSubmit: function(originalRequest)
{
var results = originalRequest.responseText;
this.target = $("target2");
this.target.innerHTML = results;
}
}
I want to pass update_id to the function onSubmit so that I can assign it as the target. According to the Prototype documentation it gets the Ajax.Response object passed as the first parameter automatically. So, that's what is referenced by originalRequest. I don't see a way to pass update_id to that function as well. How do I do that?
On a related note: I see this "name: function(){}" syntax the first time. What is that? Is that needed because it creates methods of an object? A pointer to a simple explanation would be appreciated.
Thanks very much!