Link to home
Start Free TrialLog in
Avatar of carsRST
carsRSTFlag for United States of America

asked on

JQuery - $.get

Anyone give a link or basic example using the JQuery $.get function that includes more than one parameter taken from a field on the page.

What's the difference between that and $.ajax?
ASKER CERTIFIED SOLUTION
Avatar of effx
effx
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of carsRST

ASKER

Can i replace the parameters with fields on the page?  

Something like this...

$.get(url, {ID: $("#ID").val(), name:$("#name").val()}, function(data){
alert(data);
});
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
More specifically:  
<input type="text" name="fieldTest1" />
<input type="text" name="fieldTest2" />
<input type="text" name="fieldTest3" />
<script>
var getURL = "";
$.get(getURL, {fieldTest1:$("input[name=fieldTest1]").val(), fieldTest2:$("input[name=fieldTest2]").val(), fieldTest3:$("input[name=fieldTest3]").val()}, function(data){
	alert(data);
});
</script>

Open in new window

if all the parameters come from fields in a form you may use : http://api.jquery.com/serialize/
Avatar of carsRST

ASKER

effx,

$("input[name=fieldTest1]").val()

$("#fieldTest1").val()

Will either syntax work?  or is yours specific in this aspect?



leakim,
>>if all the parameters come from fields in a form

It's not a form, but rather just inputs on a page.
Either one will work
Avatar of carsRST

ASKER

well, i guess i would like to refer to by "ID" as opposed to name.
Avatar of carsRST

ASKER

Thank you both!

Learned quite a bit in a short time.