使用 jquery 和 asp.net 进行渐进式增强
我已经建立了一个无需任何 JavaScript 即可正常工作的网站(我什至避免使用链接按钮)。现在我想使用 javascript 使用 jquery 和 json 来实现更丰富的交互式网站。有人可以向我展示一个提交按钮的示例,该按钮在启用 JavaScript 时与 jquery 和 json(用于将数据提交到服务器的部分回发)一起使用。当 javascript 被禁用时,它应该执行正常的服务器端发布。
I have built a website which working fine without any javascript (I have even avoided using link button). Now i want to use javascript using jquery and json for richer interactive website. Can somebody show me with example of a submit button which work with jquery and json (partial postback for submitting data to server) when javascript is enabled. when javascript is disabled it should do normal server side posting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多方法可以实现这种“双重动作”,我可以给你一个想法。首先,您创建一个处理程序来完成您的工作并执行您的命令。然后,您可以简单地认为通过链接和 url 参数调用此命令。
例如:
现在,您同时使用 jQuery 在链接上放置 javascript 来捕获
onclick
因此,如果用户启用了 javascript,您可以添加额外的代码,使用 ajax 来调用相同的命令,获取结果并将其打印在页面上。因此,无论有没有 javascript,命令都是相同的,您只需要对输出的方式进行一些操作即可。
我希望这会有所帮助。
There many way to do this "double action", I can give you one idea. First you make a handler that make your work and execute your commands. Then you make the simple easy think to call this command via link and url parameters.
eg:
Now at the same time you use jQuery to place on your links javascript to capture the
onclick
So if the user have enable the javascript, you add extra code that use ajax to call the same command, get the results and print it on page.So with or with out javascript the command is the same, and you only need to manipulate a little the way the output will be.
I hope that this helps.