sending post parameters using ajax

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

sending post parameters using ajax

Post by s.dot »

This seems a bit barbaric to me, but since ajax, as a congregated technology, is fairly new, it may be the only/best way to send post parameters. By turning them into a looooooooong query string.

Like the following I'm using for a wysiwyg editor type thing.

Code: Select all

function getParams()
{
	var docform = document.ddlform;
	var params = 'list=';
	params += encodeURIComponent(docform.list.value);
	params += '&list_text_size=';
	params += encodeURIComponent(docform.list_text_size.value);
	params += '&list_text_color=';
	params += encodeURIComponent(docform.list_text_color.value);
	params += '&list_text_font=';
	params += encodeURIComponent(docform.list_text_font.value);
	params += '&list_text_bold=';
	params += docform.list_text_bold.checked;
	params += '&list_text_italics=';
	params += docform.list_text_italics.checked;
	params += '&list_text_underline=';
	params += docform.list_text_underline.checked;
	params += '&list_text_overline=';
	params += docform.list_text_overline.checked;
	params += '&list_text_linethrough=';
	params += docform.list_text_linethrough.checked;
	params += '&list_text_ls=';
	params += encodeURIComponent(docform.list_text_ls.value);
	params += '&list_text_ws=';
	params += encodeURIComponent(docform.list_text_ws.value);
	params += '&list_sort=';
	params += encodeURIComponent(getCheckedValue(docform.list_sort));
	params += '&list_bgcolor=';
	params += encodeURIComponent(docform.list_bgcolor.value);
	params += '&list_border_style=';
	params += encodeURIComponent(docform.list_border_style.value);
	params += '&list_border_width=';
	params += encodeURIComponent(docform.list_border_width.value);
	params += '&list_border_color=';
	params += encodeURIComponent(docform.list_border_color.value);
	return params;
}
I may be asking a stupid question, but is there a js function to "implode" upon all form elements? Rather than manually building a long query string that is very prone to errors.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

Maybe this thread can help you - viewtopic.php?t=70134
Post Reply