About form form submission

now I"m going to write a registration page. What"s the difference between submitting a form form and directly fetching the vlaue value of input? It turns out that login and registration pages have always been done by taking values directly;

< H1 > or if there is something wrong with the writing below, please give me some advice < / H1 >

form form


<form  id="form">
        <div>
            <label for="username">:</label>
            <input type="text" name="username" required="required" placeholder="" id="username">
        </div>
        <div>
            <label for="mobile">:</label>
            <input type="text" name="mobile" required="required" placeholder=":" id="mobile">
        </div>
        <div>
            <label for="password">:</label>
            <input type="password" name="password" required="required" placeholder="" id="password">
        </div>
        <input type="submit" value="" class="btn">
    </form>
    
    //js 
     form = $("-sharpform");
    form.data().submit = function (){
        form.data() = $.post(url,{
            username:form.data().username,
            mobile: form.data().mobile,
        })
    }

Direct value method

<input type="text" name="username" required="required" placeholder="" id="username">
<input type="text" name="mobile" required="required" placeholder=":" id="mobile">

//js
var username = $("username").val();
var mobile= $("mobile").val();

$.post(url,{
    username:username,
    mobile:mobile
});

what are the advantages and disadvantages of these two ways? Forget about form validation

Feb.27,2021
The method of

1 and "direct value" looks straightforward and is suitable for implementing smaller form functions.
2, "jQ form submission". The method is that the jq library encapsulates the commonly used functions of the form, which is suitable for implementing slightly more complex functions.
3, H5 new features, also added some new attributes and tags of the form, making it easy for us to directly manipulate the form. For example, the submit button. For more information, please see api.
4, I expand the, angular (2 version or above) provides us with two forms, one is template-driven form (suitable and simple function), the other is responsive form (can achieve more complex functions, easy to maintain later, the code is more beautiful).
4. No matter which way, the performance will not be very different, otherwise the government will not announce the corresponding api, even if there are performance problems, it will be optimized in the test version, which should not be the main consideration.
5. To sum up, my suggestion is to use the "jQ form submission" method. However, according to their own needs, the subject is considered.


there is no essential difference. The operation of Jquery fetching form data is the same as taking value of input directly.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36582-2c022.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36582-2c022.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?