The problem of splicing parameters

var params={};
 $.each(that.meetArrangeList, function(index1, val1) {
    $.each(val1.child, function(index2, val2) {
        $.each(val2.child, function(index3, val3) {
            ...
            params["arrange["+index1+"].id"]=val3.meetID;
            ...
        });
    });
});

meetID this attribute is sometimes missing, and the browser does not report an error at run time. Use the POST method to submit it. When you find the parameter under form data in the browser ajax request, it is found that the item without meetID this attribute (the second piece of data in figure 1) does not have spliced id parameters.

clipboard.png

paramsidundefined

clipboard.png

the solution can be written as follows:

params["arrange["+index1+"].id"]=val3.meetID || "";

but I don"t understand why the printed one is different from the one passed by the browser. Is it because one is an object and the other is a string? Or did the browser automatically drop the content of undefined on Filter?

Mar.04,2022

the browser says: how can I tell the background that this value is undefined .

http parameters are usually serialized and deserialized. For example, a normal post request backend cannot tell whether the parameter is a string "5" or a number 5 . This feature is removed during serialization.
undefined means that it is undefined, so it is normal to ignore it when serializing. For example, there is no undefined in JSON. There is a null .

because your meetID has the case of optional, but his parent val3 is still an object, but if you want to get meetID, he just doesn't have it, but if you want to get a browser, you have to return a undefined to show that this property meetID is undefined, but there is no value in my object, but null is different. Null indicates that it has been defined but has not been given a value. When you call a post request, the data is passed as a json object, as @ cnwhy said that json does not have a undefined. So when serializing, it has been discarded

.

clipboard.png

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-1b373c1-2c06e.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-1b373c1-2c06e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?