Answered by:
how to add int not null in jquery

Question
-
User-1261921818 posted
int id=0; opAction='';
$(function () {
BindGridview();
});
function BindGridview() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "jQueryGridviewEmpEntry.aspx/BindGridview",
data: "{}",
dataType: "json",
success: function (data) {
int result = data.d;
for (int i = 0; i < result.length; i++)
{
$("#NameDetails").append('<tr><td>' + result[i].id + '</td><td>' + result[i].Fname + '</td><td>' + result[i].MName + '</td><td>'+ result[i].LastName}
}
Wednesday, December 16, 2015 12:20 PM
Answers
-
User753101303 posted
Hi,
Unclear. js is not typed so int id=0; should be rather var id=0;
Also int result=data.d wouldn't likely make sense anyway. The result is not an integer but more likely a list of object which is likeky why your code doesn't work.
What if using var result=data.d;
Also the append line seems incorrect - no closing ), missing tags??? or is this a problem when copy/pasting your actual code?
Also you could first try append("<tr><td>A</td><td>B</td><td>C</td></tr>"); for example to validate the principle and then add the actual properties one at a time so that you can better see what fails exactly.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 16, 2015 12:33 PM -
User-474980206 posted
also you could cleanup the append:
var id=0, opAction=''; $(function () { BindGridview(); }); function BindGridview() { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "jQueryGridviewEmpEntry.aspx/BindGridview", data: "{}", dataType: "json", success: function (data) { int result = data.d; for (var i = 0; i < result.length; i++) { $("<tr/>") .append($("<td/>").text(result[i].id)) .append($("<td/>").text(result[i].Fname)) .append($("<td/>").text(result[i].MName)) .append($("<td/>").text(result[i]. LastName)) .appendTo("#NameDetails"); } } }); }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 16, 2015 10:18 PM -
User61956409 posted
Hi desikankannan,
int id=0; opAction='';We declare a JavaScript variable with the var keyword. Int is not a keyword, we could not use it to declare a variable in JavaScript code. Besides, if you’d like to parse a string and return an integer, you could use parseInt() function.
http://www.w3schools.com/jsref/jsref_parseint.asp
Best Regards,
Fei Han
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 17, 2015 8:55 AM
All replies
-
User753101303 posted
Hi,
Unclear. js is not typed so int id=0; should be rather var id=0;
Also int result=data.d wouldn't likely make sense anyway. The result is not an integer but more likely a list of object which is likeky why your code doesn't work.
What if using var result=data.d;
Also the append line seems incorrect - no closing ), missing tags??? or is this a problem when copy/pasting your actual code?
Also you could first try append("<tr><td>A</td><td>B</td><td>C</td></tr>"); for example to validate the principle and then add the actual properties one at a time so that you can better see what fails exactly.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 16, 2015 12:33 PM -
User-474980206 posted
also you could cleanup the append:
var id=0, opAction=''; $(function () { BindGridview(); }); function BindGridview() { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "jQueryGridviewEmpEntry.aspx/BindGridview", data: "{}", dataType: "json", success: function (data) { int result = data.d; for (var i = 0; i < result.length; i++) { $("<tr/>") .append($("<td/>").text(result[i].id)) .append($("<td/>").text(result[i].Fname)) .append($("<td/>").text(result[i].MName)) .append($("<td/>").text(result[i]. LastName)) .appendTo("#NameDetails"); } } }); }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, December 16, 2015 10:18 PM -
User61956409 posted
Hi desikankannan,
int id=0; opAction='';We declare a JavaScript variable with the var keyword. Int is not a keyword, we could not use it to declare a variable in JavaScript code. Besides, if you’d like to parse a string and return an integer, you could use parseInt() function.
http://www.w3schools.com/jsref/jsref_parseint.asp
Best Regards,
Fei Han
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 17, 2015 8:55 AM