Why does $.getJSON() block the browser?

前端 未结 4 1012
情书的邮戳
情书的邮戳 2021-02-07 22:11

I have a page where I list hardware devices we monitor for customers. Each row displayed also shows the status of the device i.e. whether it\'s running, paused, starting up etc.

4条回答
  •  自闭症患者
    2021-02-07 22:47

    I have never had problems with $.getJSON(). It is asynchronous as far as I know. What is probably happenning is a javascript error, since you're trying to do:

    $('div[data-deviceid="' + deviceId + '"]').text(response);
    

    I'm guessing there is an error here because response is a javascript object or array, not a string. What you should do is text(response.desiredProperty) or text(response[index]) according to the type of object response is.

    Since javascript errors sometimes make our browsers behave unexpectedly, this MIGHT (only might) me your problem.

提交回复
热议问题