jquery .load() with multiple variables
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="fi开发者_开发百科eld1"]: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!
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.
精彩评论