Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 未捕获类型错误:无法读取属性';ajax';未定义的_Jquery_Ajax_Json_Post - Fatal编程技术网

Jquery 未捕获类型错误:无法读取属性';ajax';未定义的

Jquery 未捕获类型错误:无法读取属性';ajax';未定义的,jquery,ajax,json,post,Jquery,Ajax,Json,Post,我尝试通过POST调用使用AJAX从表中删除一项 ///// DELETE INDIVIDUAL ROW IN A TABLE ///// jQuery('.stdtable .delete').live('click', function (e) { //var newsId1 = $(this).attr("title"); e.preventDefault(); var p = jQuery(this).parents('tr'); if (p.next().hasClass('to

我尝试通过POST调用使用AJAX从表中删除一项

///// DELETE INDIVIDUAL ROW IN A TABLE /////
jQuery('.stdtable .delete').live('click', function (e) {
//var newsId1 = $(this).attr("title");

e.preventDefault();

var p = jQuery(this).parents('tr');

if (p.next().hasClass('togglerow'))
   p.next().remove();

p.fadeOut(function () {
    jQuery(this).remove();
});

$.ajax({
  URL: "/AdminPanel/News/DeleteNews",
  data: { "newsId": 1 },
  dataType: "json",
  type: "POST",
  success: function (msg) {
  alert(msg);
}
}); 

在这段代码中,我得到了未捕获的类型错误:无法读取未定义的属性“ajax”

您是否尝试使用
jQuery执行其余代码正在执行的操作

jQuery.ajax({
  URL: "/AdminPanel/News/DeleteNews",
  data: { "newsId": 1 },
  dataType: "json",
  type: "POST",
  success: function (msg) {
  alert(msg);
}
您可以将代码包装在一个DOM就绪函数中,该函数在函数作用域中本地设置
$
的值,这样您就可以始终使用
$

jQuery(function($) {
    // code goes here
});

我无法使用
jQuery
而不是
$
来解决这个问题

在我的例子中,我添加了源代码
jQuery.js
,并解决了这个问题,如



请注意,live()已弃用,并已从JQueryTanks o lot@adeneo的更高版本中删除。我知道这一点,但没有像你那样思考)这就是答案。谢谢你@adeneo!伙计,尝试使用js标签和框架,我6年前问过这个问题),谢谢你的评论。在我的处理项目中,它连接js labriraies失败,所以我使用这种方法。