Dot*_*row -2 javascript jquery asp.net-mvc-3
我想转换以下Jquery代码使用$ .ajax intead $ .getJSON,这将是$ .ajax代码?
$(function () {
$('#checkExists').click(function () {
$.getJSON($(this).attr('href'), function (result) {
alert(result);
if (result) {
alert('the record exists');
}
});
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
请建议
$.ajax({
url: $(this).attr('href'),
success: function (result) { ... },
dataType: 'json'
});
Run Code Online (Sandbox Code Playgroud)
另外,我建议使用event.preventDefault()而不是return false;
| 归档时间: |
|
| 查看次数: |
301 次 |
| 最近记录: |