admin管理员组文章数量:1295859
I have a problem where i need to post the data as content-type application/x-www-form-urlencoded
.
var inputData = {cId:"444",pageNo:"1",latitude:"49.153236",longitude:"12.040905"};
var data = new FormData();
data.append('data', JSON.stringify(inputData));
this.model.save(data, {
data: data,
processData: false,
cache: false,
contentType: false,
success: function (model, resultData) {
$.get(App.baseUrl + 'templates/all-offers-view.html', function (data) {
template = _.template(data, {
data: resultData
});
that.$el.html(template);
}, 'html');
},
error: function (error) {
console.log("Error");
return false;
}
});
While the above works fine in all other browsers, I am getting the following error in IE9.
SCRIPT5009: 'FormData' is undefined
view.js, line 57 character 9
line 57 being var data = new FormData();
Ive heard FormData()
is a browser dependant function and its not related to jquery library and that in IE its missing.
The reason why i am using the above method is because i have to pass data in application/x-www-form-urlencoded
format.
I cannot change the server side coding(as this is linked with an iphone app in appstore).
All i can do is try out with the client-side.
Does anyone have a solution for this?
p.s : I am using backbone.js.
I have a problem where i need to post the data as content-type application/x-www-form-urlencoded
.
var inputData = {cId:"444",pageNo:"1",latitude:"49.153236",longitude:"12.040905"};
var data = new FormData();
data.append('data', JSON.stringify(inputData));
this.model.save(data, {
data: data,
processData: false,
cache: false,
contentType: false,
success: function (model, resultData) {
$.get(App.baseUrl + 'templates/all-offers-view.html', function (data) {
template = _.template(data, {
data: resultData
});
that.$el.html(template);
}, 'html');
},
error: function (error) {
console.log("Error");
return false;
}
});
While the above works fine in all other browsers, I am getting the following error in IE9.
SCRIPT5009: 'FormData' is undefined
view.js, line 57 character 9
line 57 being var data = new FormData();
Ive heard FormData()
is a browser dependant function and its not related to jquery library and that in IE its missing.
The reason why i am using the above method is because i have to pass data in application/x-www-form-urlencoded
format.
I cannot change the server side coding(as this is linked with an iphone app in appstore).
All i can do is try out with the client-side.
Does anyone have a solution for this?
p.s : I am using backbone.js.
Share Improve this question asked Oct 21, 2013 at 5:04 Roy M JRoy M J 6,9487 gold badges53 silver badges79 bronze badges 2- 3 The patibility table at MDN indicates you might have issues with more than IE. There is also a link for how to submit the form data without the formData API. – RobG Commented Oct 21, 2013 at 5:18
- :(.. that is very bad... ill try out the fix... – Roy M J Commented Oct 21, 2013 at 6:12
1 Answer
Reset to default 3Try below code:
if(typeof FormData == "undefined"){
var data = [];
data.push('data', JSON.stringify(inputData));
}
else{
var data = new FormData();
data.append('data', JSON.stringify(inputData));
}
Hope this help you
本文标签: javascript39FormData39 is undefined in IE onlyStack Overflow
版权声明:本文标题:javascript - 'FormData' is undefined in IE only - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741617235a2388594.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论