carsRST
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?
What's the difference between that and $.ajax?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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>
if all the parameters come from fields in a form you may use : http://api.jquery.com/serialize/
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.
$("input[name=fieldTest1]"
$("#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
ASKER
well, i guess i would like to refer to by "ID" as opposed to name.
ASKER
Thank you both!
Learned quite a bit in a short time.
Learned quite a bit in a short time.
ASKER
Something like this...
$.get(url, {ID: $("#ID").val(), name:$("#name").val()}, function(data){
alert(data);
});