使用jquery从JSON数据填充表单

时间:2016-01-22 01:28:31

标签: jquery getjson

我不知道为什么它不起作用

var mongoose = require('mongoose'),
Schema = mongoose.Schema;

mongoose.connect(process.env.MONGO_URI);

var userSchema = new Schema({
  username: String,
  password: String,
  books: [{type: Schema.Types.ObjectId, ref: 'User'}]
  }
);

var bookSchema = new Schema({
  bookid: {type:String, unique:true, required:true},
  imgURL: String
});

module.exports.user = mongoose.model('User', userSchema);
module.exports.book = mongoose.model('Book', bookSchema);

1 个答案:

答案 0 :(得分:-1)

您的JSON格式不正确。 用这种格式调整

像这样调整你的代码

{ “dataOne”:[{“keyOne”:“valueOne”,“keyTwo”:“valueTwo”},{“keyOne”:“valueOne”,“keyTwo”:“valueTwo”},],  “dataTwo”:[{ “keyOne”: “valueOne”},{ “keyOne”: “valueOne”}] }