Reputation: 518
success: function (data) {
if (data.length > 0) {
$('#search_result').empty();
$.each(data, function (key, value) {
$('#search_result').append("<tr>"+
"<td>"+
value.Experience+
"</td>"+
"<td>"+
'<?php echo anchor('site/apply',"Apply") ?>'+
"</td>"+
"<td>"+
value.Id+
"</td>"+
"</tr>"
)
})
}
Above is the success details for my search using ajax..I need to pass value.Id
through the href attribute of anchor tag.How could it is possible for me?
Upvotes: 0
Views: 652
Reputation: 518
success: function (data) {
if (data.length > 0) {
$('#search_result').empty();
$.each(data, function (key, value) {
$('#search_result').append("<tr>"+
"<td>"+
value.Experience+
"</td>"+
"<td>"+
"<a href='site/apply/"+value.Id+"''>Apply</a>"+
"</td>"+
"<td>"+
value.Id+
"</td>"+
"</tr>"
)
})
}
This method worked . .
Upvotes: 0
Reputation: 1449
I thinks this should work.
success: function (data) {
if (data.length > 0) {
$('#search_result').empty();
$.each(data, function (key, value) {
var link = "<a href='<?php echo base_url() ?>site/apply/'+value.Id>Apply</a>";
$('#search_result').append("<tr>"+
"<td>"+
value.Experience+
"</td>"+
"<td>"+link+"</td>"+
"<td>"+
value.Id+
"</td>"+
"</tr>"
)
})
}
Upvotes: 1