I'm currently working on an ajax call that will update the value of a textbox:
<div id="PNIncrementDiv" style="position:absolute; left: 730px; top: 15px; width: 350px;" class="">
<input id="TBIncrementTextBox" class="textbox" type="text" style="position:absolute; top:25px; left: 75px; width: 60px; height: 40px;" runat="server" />
</div>
My ajax function, which returns an integer, and Is tested to be returning the correct answer is below:
getIncrement: function (id) {
$.ajax({
url: "<%=Session("BaseUri")%>" + '/handlers/DataEntry/SPC_InspectionInput.ashx',
type: 'GET',
data: { method: 'getIncrement', args: { IncrementId: id} },
success: function (data) {
console.log(data);
Inc_Num = data;
$('#TBIncrementTextBox').val(data.toString());//nothing happens!
},
error: function (a, b, c) {
alert(c);
}
});
}
However, when I try to change the value of the textbox, nothing happens. What am I doing wrong?
", the second with'. It's confusing, but it's valid. I agree it should be changed though. There's no need to append the strings at all as the first value is coming from the server.console.log(data);?runat="server"attribute at the end of the element. That's the problem. If you check the HTML source in your browser you'll see that theidhas been changed at runtime by ASP.Net. You need to retrieve the element using theClientIDproperty instead - or use a class.