在下面给出的代码中,我可以在MS Edge中附加数据,但是在读取该值时,我没有给Microsoft的任何选择。 有什么解决方法可以读取已经附加的值?任何帮助,将不胜感激。谢谢!
let formData = new FormData();
formData.append("Key1", "Key1-Value1");
formData.get("Key1"); // Not Supported in Edge
formData.getAll(); // Not Supported in Edge
formData.entries(); // Not Supported in Edge
formData.keys(); // Not Supported in Edge
formData.value(); // Not Supported in Edge
答案 0 :(得分:0)
在我看来,您可以定义一个数组以将实体存储在前端,然后可以从该数组中筛选数据,而不是FormData。请参考以下代码:
var datalist = []; //define an array to store the formdata entities.
let formData = new FormData(); //the formdata, you could send it to server side.
formData.append("Key1", "Key1-Value1");
formData.append('Key1', 'Chris');
formData.append('Key2', 'Bob');
//push data into the array.
datalist.push({ Key: "Key1", value: "Key1-Value1" });
datalist.push({ Key: "Key2", value: "Chris" });
datalist.push({ Key: "Key3", value: "Bob" });
//based on the key value to filter entities.
var entity = jQuery.grep(datalist, function (item) {
return item.Key == "Key1";
});
//get all keys.
var allkeys = jQuery.map(datalist, function (item) {
return item.Key;
});
//get all values.
var allvalues = jQuery.map(datalist, function (item) {
return item.value;
});
答案 1 :(得分:0)
如果我在断点或其他任何地方,请转到“控制台”选项卡,然后输入console.log(...formData)