开发者

Best way to store data for sending via Ajax

开发者 https://www.devze.com 2023-02-23 00:22 出处:网络
What is the best way to store data which should be sent via Ajax using jQuery? I usually utilise: A hidden <input /> with my value to be sent:

What is the best way to store data which should be sent via Ajax using jQuery? I usually utilise:

  1. A hidden <input /> with my value to be sent:

    <input type='hidden' value='myValue'>
    
  2. A link with a 开发者_运维百科data attribut:

    <a href='apage.php' data-val='myValue'>
    

Note: I do not want to use plugins.


Assuming you mean which is better to store your data, the first way (input hidden with my value to be sent).

This is of course unless you're explicitly using HTML5, which isn't is recommended just yet. If you are, it's completely upto you, although the element metadata/html5 way is probably better!

But this doesn't seem to be anything to do with AJAX than just in-page data storage, am I missing something?

0

精彩评论

暂无评论...
验证码 换一张
取 消