小编use*_*079的帖子

在python中将字符串转换为json

json.loads('{"name": "Sam"}')
{u'name': u'Sam'}
Run Code Online (Sandbox Code Playgroud)

这应该不显示

{"name": "Sam"}

Python 2.7

有什么问题?

python json python-2.7

0
推荐指数
1
解决办法
113
查看次数

如何防止在jQuery中进一步执行

我正在迭代一个表格

$('#table1 tr').each(function(event){
    if($(this).hasClass('class1')){
       $(this).removeClass('class1');
       $(this).addClass('class2');
       event.stopPropagation();
       event.stopImmediatePropagation();
    }
});
Run Code Online (Sandbox Code Playgroud)

但这并不能阻止传播.

jquery

-1
推荐指数
1
解决办法
37
查看次数

在python中创建一个类的对象

我在python中创建了一个类,为什么我会收到此错误?

class Car:

    def __init__(self, name, brand):
        self.name = name
        self.brand = brand

    def printDetails(self):
        return 'Name: ', self.name, '\nBrand: ', self.brand

    c1 = Car('A4', 'Audi')
Run Code Online (Sandbox Code Playgroud)

NameError: name 'Car' is not defined

python

-1
推荐指数
1
解决办法
41
查看次数

json解析错误:预期'}'

我正在打一个ajax电话

$.ajax({
   url: 'url',
   data: {},
   method: 'POST',
   enctype: 'multipart/form-data',
   dataType: 'json',
   success: function(data){
      // handle success
   },
   error: function(data, textStatus){
       //handle error
   }
});
Run Code Online (Sandbox Code Playgroud)

我的json回复是

{
    person: {
        name: 'John'
    }
Run Code Online (Sandbox Code Playgroud)

如您所见,json响应不是很好.因此我得到了错误

json parse error: Expected '}'
Run Code Online (Sandbox Code Playgroud)

在里面

error: function(data, textStatus){

}
Run Code Online (Sandbox Code Playgroud)

如何,我可以忽略这个解析错误并继续执行,因为我收到了响应.

javascript ajax jquery json

-3
推荐指数
1
解决办法
4606
查看次数

标签 统计

jquery ×2

json ×2

python ×2

ajax ×1

javascript ×1

python-2.7 ×1