Trying To Pass Form Values To Load Json Request

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jbh
Forum Commoner
Posts: 89
Joined: Tue Dec 05, 2006 7:01 pm

Trying To Pass Form Values To Load Json Request

Post 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.
jbh
Forum Commoner
Posts: 89
Joined: Tue Dec 05, 2006 7:01 pm

Re: Trying To Pass Form Values To Load Json Request

Post 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.
Post Reply