Been fighting trying to add a row to a table using prototype Ajax. I've tried a couple methods and keep running into road blocks. Maybe too much Ajax

The problem is most likely in your Javascript code. To add a row to a table with prototype, you would do something like this:

// 1. make your Ajax request
// 2. Active4D code builds a complete table row (<tr><td>content</ td></tr>)
// 3. in your Ajax onSuccess callback, do this:

onSuccess: function(request)
{
   new Insertion.Bottom($('mytable'), request.responseText);
}


with a get request, data was truncated ( - expected since not encoded and can't find an encode parameters in prototype) with a post request using /4dcgi I get a server error from 4D. Without 4dcgi, I get and active4D error, data not in right format.

To encode parameters, use the Javascript function encodeURIComponent (text), or pass a mapping object in the Ajax options like this:

var data = {
    name: $F('f_username'),
    address: $F('f_address'),
    city: $F('f_city')
};

var options = {
   method: 'post',
   parameters: data,
   onSuccess: mySuccessCallback.bind(this)
};

new Ajax.Request('/4dcgi/qry_foo.a4d', options);

Regards,

   Aparajita
   www.aparajitaworld.com

   "If you dare to fail, you are bound to succeed."
   - Sri Chinmoy   |   www.srichinmoylibrary.com


_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to