Page 1 of 1

Trying To Pass Form Values To Load Json Request

Posted: Fri Oct 23, 2009 11:39 am
by jbh
EDIT:

Hey,

Below is a function that takes a click of a button from a form and is supposed to load up the values and append them to a PHP
page where I can use the values to load JSON data. I have a variable to serialize the data

var formData = $('form').serialize();

The problem is, I need to append formData's output as a querystring into the results.php url below. I cannot seem to do this. How does one accomplish this?

Thanks. Below is the failed code that can spit out the data but I cannot append it to the results.php url:

Code: Select all

 
 
 $('#my_button').click(function () { 
  var formData = $('form').serialize();
  alert(formData);
[b]loadJSON("http://www.mysite.com/results.php?id=1&data=' + formData' ");[/b]
    });
 
 
Thank you for your time.

Re: Trying To Pass Form Values To Load Json Request

Posted: Sat Oct 24, 2009 4:19 pm
by jbh
Update. I found a solution.

I turn the url into a variable and create a var that comes from the jquery serialize function.
I append that variable to the url variable and load that through the json function.

(slaps head).

Ty for your time.