6

I am using the jquery .load() method for a search. I have figured out how to send one variable, but I need to send many.

WITH ONE

var field1 = ($('#form1 input[name="field1"]:text').val());
$('#results').load("/search/show.php", {field1: field1});

How would I do two variables? THIS WONT WORK

var field1 = ($('#form1 input[name="field1"]:text').val());
var field2 = ($('#form1 input[name="field2"]:text').val());
$('#results').load("/search/show.php", {field1: field1}{field2: field2});

I'm sure there is an easy way to send multiple variables, I just don't know how!

1 Answer 1

7

You're looking for:

var field1 = ($('#form1 input[name="field1"]:text').val());
var field2 = ($('#form1 input[name="field2"]:text').val());
$('#results').load("/search/show.php", {field1: field1, field2: field2});

Check out object literals on the MDC.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the help and thanks so much for the reference, it will be very helpful in the future!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.