我保存我的骨干模型没有id,因此它使用POST协议将参数发送到我的REST API。但是我无法捕获这些参数,PUT工作正常并更新数据库但POST方法似乎会导致问题。我注意到的一件事是我可以捕获字符串参数,但整数参数返回未定义。
我的php
if($request_method == 'POST') {
$post_data = file_get_contents("php://input");
$post_data = json_decode($post_data, TRUE);
echo $post_data['name'];
}
骨干代码
createdata: function(event){
var newModel = new App.Models.Question({name:$("#_name").val(), surname:$("#_surname").val(), age:$("#_age").val()});
newModel.save({},{
success: function (model, response) {
alert(response.responseText);
},
error: function (model, response) {
alert(response.responseText);
},
wait: true
}
);
console.log(this.myCollection.toJSON());
},
答案 0 :(得分:0)
我已经有一段时间完成了这个项目但仍然想发布对我来说工作正常的代码。
package demo;
public class ProducerConsumer {
public static int SAMPLE_INT = 0;
public static void main(String[] args) {
PC pc = new PC();
Thread changer = new Thread(new Runnable() {
public void run(){
try {
pc.producer();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
Thread listener = new Thread(new Runnable(){
public void run() {
try {
pc.consumer();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
changer.start();
listener.start();
}
}
class PC {
Object lock = new Object();
public void producer() throws InterruptedException {
synchronized(this){
for (int i=0; i<5; i++){
ProducerConsumer.SAMPLE_INT++;
System.out.println("Changed value of int to: " + ProducerConsumer.SAMPLE_INT);
wait();
notify();
}
}
}
public void consumer() throws InterruptedException{
synchronized(this){
for (int i=0; i<5; i++){
System.out.println("Receieved Change: " + ProducerConsumer.SAMPLE_INT);
notify();
wait();
}
}
}
}