vgapp 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,6 +84,11 @@ const Ajax = {
84
84
  let x = Ajax.x();
85
85
  x.open(method, url, async);
86
86
  x.setRequestHeader("X-Requested-With", "XMLHttpRequest");
87
+
88
+ if (!Ajax.checkFormData(data) && method === 'POST') {
89
+ x.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
90
+ }
91
+
87
92
  x.onreadystatechange = function () {
88
93
  if (x.readyState === 4) {
89
94
  switch (x.status) {
@@ -118,7 +123,20 @@ const Ajax = {
118
123
  },
119
124
 
120
125
  post: function (url, data, callback, async) {
126
+ if (!Ajax.checkFormData(data)) {
127
+ data = JSON.stringify(data);
128
+ }
121
129
  Ajax.send(url, callback, 'POST', data, async)
130
+ },
131
+
132
+ checkFormData: function (obj) {
133
+ return obj &&
134
+ typeof obj === 'object' &&
135
+ obj.constructor &&
136
+ obj.constructor.name === 'FormData' &&
137
+ typeof obj.append === 'function' &&
138
+ typeof obj.get === 'function' &&
139
+ typeof obj.getAll === 'function';
122
140
  }
123
141
  };
124
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vgapp",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "",
5
5
  "author": {
6
6
  "name": "Vegas Studio",
@@ -29,7 +29,6 @@
29
29
  "css-loader": "^7.1.2",
30
30
  "html-webpack-plugin": "^5.6.3",
31
31
  "mini-css-extract-plugin": "^2.9.0",
32
- "node-sass": "^9.0.0",
33
32
  "postcss-loader": "^8.1.1",
34
33
  "postcss-preset-env": "^9.6.0",
35
34
  "sass": "^1.77.8",