[jQuery] Please help (first attempt using jQuery

[jQuery] Please help (first attempt using jQuery


Hi all,
This is my first development project using jQuery (actually it didn't
start out using it but someone recommended I did along with using an
ASP.Net WebService Method (both of which I had never used before) so
there are a lot of new things for me here. Here is what I have:
<script language="javascript" src="js/json2.js" type="text/
javascript"></script>
<script language="javascript" src="js/jquery-1.2.6.min.js" type="text/
javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(
function() {
$("#cmdCheckBid").click(JSCheckBid);
$("#cmdTester").click(function() {

alert(document.getElementById("<%=lblItemID.ClientID %>").innerHTML);

alert(document.getElementById("<%=lblNextBid.ClientID %>").innerHTML);
});
}
)
function JSCheckBid()
{
var itemID = document.getElementById("<%=
lblItemID.ClientID %>").innerHTML;
var nextBid = document.getElementById("<%=
lblNextBid.ClientID %>").innerHTML;
//alert(itemID);
//alert(nextBid);
var value = {'ItemID': itemID, 'NextBid': nextBid};
var strParams = JSON.stringify(value);
$.ajax(
{
type: "POST",
url: "PlaceBidJSON.aspx/CheckBid",
dataType: "json",
data: strParams,
contentType: "application/json; charset=utf-8",
success: alert('success'),
error: function(xhr,msg) {
alert('error:' + xhr.responseText)
}
});
}
</script>
<a id='cmdTester' href='#'>Tester</a><br />
<a id='cmdCheckBid' href="#">Check Bid</a><br />
And here is my WebService Method:
<WebMethod()> _
Public Shared Function CheckBid(ByVal intItemID As Integer, ByVal
dblNextBid As Double) As Integer
Dim strUserName As String = getUserName()
Dim SqlCon As New
SqlConnection(ConfigurationManager.ConnectionStrings("AuctionConnectionString").ConnectionString)
SqlCon.Open()
Dim cmd As New SqlCommand("CheckBid", SqlCon)
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Parameters.AddWithValue("ItemID", intItemID)
cmd.Parameters.AddWithValue("UserName", strUserName)
cmd.Parameters.AddWithValue("BidAmount", dblNextBid)
Dim intResult As Integer = cmd.ExecuteScalar
cmd.Dispose()
SqlCon.Close()
Return intResult
'1 = Success
'2 = Current user already has highest bid
'3 or higher (user has been outbid) is the amount of the
highest bid
End Function
If I click on "Tester", then I get the proper values of "0001" and
"$80.00" respectively for the values of lblItemID and lblNextBid. If
I add an alert inside JSCheckBid for both of these variables (itemID
and nextBid), they get set properly. However, when I click on "Check
Bid", I first get an alert that says "success" and then I get one that
says:
error: {"Message":"Invalid web service call, missing value for
parameter: \u0027intItemID\u0027.","StackTrace":" at
System.Web.Script.Services.WebServiceMethodData.CallMethod(Object
target, IDictionary ` 2 parameters)\r\n at
System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object
target, IDictionary ` 2 parameters)\r\n at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext
context, WebServiceMethodData methodData, IDictionary ` 1 rawParams)\r
\n at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
context, WebServiceMethodData methodData)",
"ExceptionType":"System.InvalidOperationException"}
I'm not sure why this is as the values of the variables are there.
The stringify method worked properly with another function I used
where it had one parameter. Should I be calling it differently for
multiple parameters?
Thanks,
Aaron