To get data in HTML using jQuery after a successful AJAX request, you can use the $.ajax() function to send the AJAX request and use the success callback to handle the response.
Assuming that the AJAX response returns HTML data, you can use the html() method to set the HTML content of an element in your web page.
$.ajax({
url: 'your-url-here',
method: 'GET',
success: function(data) {
// Use the html() method to set the HTML content of an element
$('#your-element-id').html(data);
},
error: function(xhr, status, error) {
// Handle the error
console.log(error);
}
});
In this example, the url parameter specifies the URL that you want to send the AJAX request to, and the method parameter specifies the HTTP method to use (in this case, GET).
The success callback function is called when the AJAX request is successful, and the data parameter contains the response data returned by the server.
Inside the success callback function, we use the html() method to set the HTML content of an element with the ID your-element-id to the response data.
If the AJAX request fails, the error callback function is called, and the xhr, status, and error parameters contain information about the error. You can use this information to handle the error appropriately.
success: function(data) {
console.log('update ho gaya successfully');
// adding alert messages
const parsed = JSON.parse(JSON.stringify({data}));
console.log(parsed);
const myValue = parsed.data[website];
console.log(myValue);
$.each(parsed, function(i, link) {
$('#mypasswordnew').val(link.pro_engg);
});
HTML part
<input type="text" name="mypasswordnew" id="mypasswordnew" class="form-control" autocomplete="off" />
==========================================================
$('#mywebsite').val(html.data.website);
$('.modal-title').text("Upload private key to decrypt");
$('#myformModal').modal('show');
success: function(html) {
console.log('value aa gaya edit ke page pe');
console.log(html);
var task= html.data.type_of_task
console.log("task yehi hai");
console.log(task);
$('#mytype_of_task').val(html.data.type_of_task);
$('#mywebsite').val(html.data.website);
$('#myemail_address').val(html.data.email_address);
$('#myproject_manager').val(html.data.maintenance_engineer);
$('#mypassword').val(html.data.password);
$('#myuser_name').val(html.data.user_name);
$('#mywizard_project_name').val(html.data.wizard_project_name);
$('#myadmin_email').val(html.data.admin_email);
$('#myadmin_id').val(html.data.admin_id);
$('#mytoken_engineer').val(html.data.token_engineer);
$('#mytokenid').val(html.data.tokenid);
$('#myid').val(html.data.id);
$('.modal-title').text("Upload private key to decrypt");
$('.modal-title_delete').text("Assets Delete");
$('#action_button').val("Update");
$('#action').val("Update");
$('#myformModal').modal('show');
$('#hidden_id').val(id);
}
In Html Part
<input type="hidden" name="mymaintenance_engineer" id="myproject_manager" class="form-control" autocomplete="off" />
<input type="hidden" name="password" id="mypassword" class="form-control" autocomplete="off" />
<input type="hidden" name="user_name" id="myuser_name" class="form-control" autocomplete="off" />
<input type="text" name="mypasswordnew" id="mypasswordnew" class="form-control" autocomplete="off" />
<input type="hidden" name="website" id="mywebsite" class="form-control" autocomplete="off" />
<input type="hidden" name="email_address" id="myemail_address" class="form-control" autocomplete="off" />
<input type="hidden" name="type_of_task" id="mytype_of_task" class="form-control" autocomplete="off" />
<input type="hidden" name="wizard_project_name" id="mywizard_project_name" class="form-control" autocomplete="off" />
<input type="hidden" name="myadmin_email" id="myadmin_email" class="form-control" autocomplete="off" />
<input type="hidden" name="myadmin_id" id="myadmin_id" class="form-control" autocomplete="off" />
<input type="hidden" name="mytoken_engineer" id="mytoken_engineer" class="form-control" autocomplete="off" />
<input type="hidden" name="mytokenid" id="mytokenid" class="form-control" autocomplete="off" />
<input type="hidden" name="myid" id="myid" class="form-control" autocomplete="off" />
success: function(data) {
console.log('success main mamager id value a rha hai ki nahi');
var p_name = ('#token_manager');
// $(p_name).empty();
$.each(data, function(i, link) {
$('#token_manager').append('<option name="' + link.token + '" value="' + link.token + '">' + link.token + '</option>');
});
<div class="form-group">
<label class="control-label">Select public key to enrypt </label>
<select name="token_engineer" id="token_manager" class="form-control">
<option value="default" class="form-control text-dark">Select Token </option>
</select>
</div>
Oldest comments (0)