ng-table not working for dynamic data

后端 未结 6 1896
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 23:53

I have created a table and I am using http to load the data in the tables. So, in every click, my table data is changing, but I don\'t see the updated data in the table. I h

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-04 00:31

    I was working on ng-tables with dynamic data as well (adding/removing),
    I was using an ajax call to make changes to the database, and the success: function() {} property make changes to the tableParams
    but changes wouldn't show on the page unless i refreshed it, with a few console.log()'s, I found out that the success: function() {} actually never executes
    but there's another function that always executes, complete: function() {} I know it's logically wrong to put the code that's supposed to work only after a successful call into complete: function() {} but if my success: function isn't working, this fix isn't that bad, especially knowing that the change is always successfully made to the database
    it's strange because the success call works on other pages of the website, but it doesn't on some others. EDIT:
    well, this fix still doesn't solve the problem when the length of the data doesn't change "editing the text in the data" as mentioned above,, frustrating...

    $.ajax({
            type: "POST",
            url: /*some url*/,
            data: JSON.stringify({ /*some variable*/ }
            }),
            contentType: "application/json; charset=utf-8",
            dataType: "Json",
            success: function () {  // would never execute even if it's a successful call
                console.log("success"); 
            },
            error: function() {  // optional, personally didn't try it
                console.log("error"); 
            }
            complete: function () {  //always executes regardless of the result
                console.log("complete"); 
            }
        });
    

提交回复
热议问题