“JSON Remove button” 按下后,几秒后数据重新出现。

huangapple go评论132阅读模式
英文:

Data reappears after a few seconds when "JSON Remove button" is pressed

问题

I'm currently in the process of creating a HTTP web service that will return data in JSON, XML and String formats. When entering a string and pressing "JSON Search" it will return data back from a database stored in Google SQL. However when I press the "JSON Remove" button next to the "JSON Search" button the data is cleared and then reappears after a few seconds. a br tag between the buttons seems to resolve the issue but messes around with the layout which I don't want to happen.

Code is within the linked image

英文:

I'm currently in the process of creating a HTTP web service that will return data in JSON, XML and String formats. When entering a string and pressing "JSON Search" it will return data back from a database stored in Google SQL. However when I press the "JSON Remove" button next to the "JSON Search" button the data is cleared and then reappears after a few seconds. a br tag between the buttons seems to resolve the issue but messes around with the layout which I don't want to happen.

Code is within the linked image

Image

答案1

得分: 0

按钮的默认 type 是 "submit"。您已明确将您的 JSON 搜索按钮设置为提交按钮,但技术上您的删除按钮也是一个提交按钮。添加属性 type="reset" 可以将其设置为一个实际清除表单的按钮。或者如果您只想让它执行事件处理程序而不执行任何其他操作,可以使用 type="button"

目前的问题是,您可能有一个处理程序,当单击删除按钮时会清除数据,但由于它是一个(不经意的)提交按钮,它也会触发另一个查询。

英文:

The default type of a <button> is "submit". You have explicitly set your JSON Search button to be a submit button, but technically so is your Remove button. Add the attribute type="reset" to have that one be a button that actually clears the form. Or type="button" if you just don't want it to do anything except run your event handler.

The problem right now is that you probably have a handler that is clearing the data when you click the Remove button, but since it's an (unintended) submit button, it's also kicking off another query.

huangapple
  • 本文由 发表于 2020年1月7日 02:00:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616811.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定