471,893 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,893 software developers and data experts.

AJAX Post objects

blyxx86
256 100+
Hey everyone,

I'm fairly new to javascript. I hardly ever use it, but my newest project is demanding that I have 'dynamic' drop downs where the user can type in their partial matches.

So, I come across jQuery Autocompletes. Works wonderful, except the framework I am using doesn't like using GET methods and they are less safe than POST data.

So I modified the code of the autocomplete to allow me to send POST data, but I am now stuck getting multiple pieces of POST data to pass to the page. Can someone help me?

Expand|Select|Wrap|Line Numbers
  1. $.post(options.url, {p:q}, function(data) {
  2.                 data = parseData(data);
  3.                 //addToCache(q, data);
  4.                 receiveData(q, data);
  5.             });
  6.  
  7.  
  8. options.extraParams = options.extraParams || {a:1,b:2}; // for example
  9.  
How would I pass both {p:q} and options.extraParams to the $.post function?

I have tried {p:q} + options.extraParams but that only posts "[object Object][object Object]"

any help would be appreciated.

Thank you!
May 4 '09 #1
1 1373
blyxx86
256 100+
Hey everyone!
I found a solution to the problem.

jQuery had a built-in function to do just this. My lack of knowledge of what the objects are called made it difficult to define a decent enough search for my purpose.

A few texts between a friend and me helped me define the words for my search and expand the thought.

Associative arrays in javascript appear to be called objects. Their values are properties. Below is the code that allows the merge to take place.

http://docs.jquery.com/Utilities/jQuery.extend
Expand|Select|Wrap|Line Numbers
  1. var settings = { validate: false, limit: 5, name: "foo" };
  2. var options = { validate: true, name: "bar" };
  3. jQuery.extend(settings, options);
  4.  
May 4 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.