我使用superagent作为我的ajax库,
我可以使用FormData()方法获取表单数据并进行ajax GET吗?
这是我的代码:
var React = require('react');
var ReactDOM = require('react-dom');
var request = require('superagent');
var App = React.createClass({
handleSubmit: function(e) {
e.preventDefault();
request
.get('/gg')
.query(new FormData(e.target))
.end(function() {
console.log('gg')
});
},
render: function() {
return (
<form onSubmit={this.handleSubmit}>
<input name="a" />
<select name="b">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<button type="submit">submit</button>
</form>
);
}
});
ReactDOM.render(<App/>, document.getElementById('app'));