tags:

views:

32

answers:

5

I'm not sure why the following wouldn't be working. I am getting a blank string when I attempt to retrieve the text from the FirstName textbox in my HTML. The DIV is currently hidden, would that make any difference? Any ideas?

jQuery:

 $.ajax({ url: 'go.aspx?FirstName=' + $("#FirstName").text()});

HTML:

<input name="FirstName" type="text" id="FirstName" style="width:240px;" />
+5  A: 

Use val:

$.ajax({ url: 'go.aspx?FirstName=' + $("#FirstName").val()});

Additionally, if all you are doing is that simple call, you might want to use $.get instead:

$.get('go.aspx', { 'FirstName':$("#FirstName").val() });
Doug Neiner
A: 

You should use the val for the value of input fields $("#FirstName").val()

TGuimond
A: 
$.ajax({ url: 'go.aspx?FirstName=' + $("#FirstName").val()});
Majid
A: 

Use the val() method instead of text().

http://api.jquery.com/text/

http://api.jquery.com/val/

Edit: You've gotta be fast at this place...

David Johnstone
A: 

.val() is the jQuery function you want.

see

http://api.jquery.com/val/

Hogan