undefinedfix
Sign in

How to use JQ to modify the requested data, page refresh can not see

ypmyl edited in Tue, 29 Jun 2021

The background is the data written in PHP, and there is no separation. When I use JQ to modify the text of the page, it will refresh the previous things. How to make it refresh and not display

6 Replies
bopa
commented on Tue, 29 Jun 2021

According to the loading order of DOM, you can try to hide the area first and then modify it

<div id ="a">
<script>
document.getElementById('a').style.display = 'none';
</script>
  <div id="b">你想要修改的数据</div>
</div>

<script>
window.onload=function(){
  // 这里也可以换成jquery
  // 做任何你想做的事
  document.getElementById('a').style.display = 'block';
};
</script>
DeliriousPuppet
commented on Tue, 29 Jun 2021

When the page is loaded, it will be requested. What you requested must be an array. Find an element in the array that you want to modify, modify it directly, and then assign a value to the element containing text $(". Demo"). Text (the requested data you have modified)

mozilla_firefox
commented on Wed, 30 Jun 2021

You modify the page text submitted to the background, so that the background to save your modified content, and then refresh, it will not be modified

okgym
commented on Wed, 30 Jun 2021

JQ only changes the appearance of the client. You need to submit it to the back end and save it to the server. When the page is displayed, you can get the data of the server. OK

gearcoded
commented on Wed, 30 Jun 2021

Save the text of the page modified by JQ to the server, refresh again to get the background data, which is the value you changed

Amer
commented on Wed, 30 Jun 2021

If the background data can't be saved, make a front-end cache and session storage. When you come in (refresh), check the identification in the session storage. If the conditions are met, directly take the data you just requested in the background from the session storage. If the conditions are not met, directly use the previous data. Take a look at session storage

lock This question has been locked and the reply function has been disabled.