User-707554951 posted
Hi zjm_zjm
From your description, I make an simple example, it works well in my application, you could refer to the code below:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
function getUserName() {
var $modal = $('#editUserPopUp'),
$userName = $modal.find('#userName');
var text = "555";
$.ajax({
type: "POST",
url: "CS.aspx/GetCurrentTime",
data: '{id: "User" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var s = response.d;
$userName.val(s);
$modal.modal("show");
},
failure: function (response) {
alert(response.d);
}
});
}
</script>
<body>
<button onclick="getUserName()" id="Foo Bar">Open Modal</button>
<div class="modal fade" id="editUserPopUp" tabindex="-1"
role="dialog" aria-labelledby="helpModalLabel" aria-hidden="true">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Update Password</h4>
</div>
<div class="modal-body">
<form class="EditUserBody" role="form" id="usermanagement_editUser="novalidate" method="POST">
<div class="input-group col-md-8">
<span class="input-group-addon">User Name</span>
<input class="form-control" id="userName" type="text" class="input-medium" disabled />
</div>
</form>
</div>
</div>
</div>
</div>
</body>
[System.Web.Services.WebMethod]
public static string GetCurrentTime(string id)
{
string s = "Hello" + id;
return s;
}
Hope this can help you. If you have any question and confusion about the problem. Please don't hesitate to let me know.
Best regards
Cathy