简体   繁体   English

如何使用ajax调用更新清单的状态

[英]How to update the status of the checklist with ajax call

I am trying to update the status of the checklist on click of a button.我正在尝试通过单击按钮来更新清单的状态。 Can I achieve it by making individual ajax calls pertaining to the checklist item or can I achieve it by making one call and still update it as soon as it is completed.我可以通过对清单项目进行单独的 ajax 调用来实现它,还是可以通过一次调用来实现它,并在完成后立即更新它。

I have attached the template of how it looks and what I am trying to achieve.我附上了它的外观和我想要实现的模板。

Sorry tried to upload the CSS images files, however not able to do that.抱歉尝试上传 CSS 图像文件,但无法上传。

This how it looks这是它的样子

在此处输入图片说明

Thanks in advance.`提前致谢。`

 div { width: 30%; top: 50%; left: 50%; border: 1px solid black; } ul { list-style: none; width: 30%; } li { padding-top: 20px; } img { float: right; display: inline; text-align: middle; transition: all .2s ease; } .pass { background: url('status1.png') no-repeat -2px -47px; width: 20px; height: 20px; } .fail { background: url('status1.png') no-repeat -2px -70px; width: 20px; height: 20px; } .inprog { background: url('status1.png') no-repeat -2px -25px; width: 20px; height: 20px; } .pend { background: url('status1.png') no-repeat -2px -3px; width: 20px; height: 20px; }
 <div> <h4> Please Wait...... Performing checks on</h4> <ul> <li> check1 <img src="img_trans.gif" class="pass" /></li> <li> check2 <img src="img_trans.gif" class="fail" /></li> <li> check3 <img src="img_trans.gif" class="inprog" /></li> <li> check4 <img src="img_trans.gif" class="pend" /></li> </ul> </div>

` `

You can do this by two ways你可以通过两种方式做到这一点

1)Make ajax call and prepare the content and append 1)进行ajax调用并准备内容并追加

2)Again make an ajax call and based on the response dynamically assign classes of your 2)再次进行ajax调用并根据响应动态分配您的类

(pass, fail, inprog, pend)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM