javascript - Ajax-JSON method 405 -


i don't understand error, want add new data in file json ajax :

my script :

function question(title, fa, sa){     this.title = title;     this.fa = fa;     this.sa = sa; }   $(function() {     $('#form').submit(function(event){         event.preventdefault();          var title = $('#title').val();         var fa=$('#firstalternative').val();         var sa=$('#secondalternative').val();         var q1 = new question(title,fa,sa);     $.ajax({         url:"http://localhost:5000/gree/questions",         type:"post",         contenttype:"application/json",         data : json.stringify(q1),         datatype:"json",         jsonpcallback:'jsoncallback',         jsonp:false,         success:function(data){             alert("hahahahahhahah");             },         error: function(){console.log('error');}          });         return false; }); 

});

my form :

my form basic, id , method="post".

<form id="form"  name="formquestions" style="text-align:center;" method="post">     <p>         <h3>titre de la question </h3><input type="text" id="title" style="height:50px;font-size:14pt;" size="50" required>     </p>     <p>         <h3>réponse 1 </h3><input style="height:50px;font-size:14pt;" size="50" type="text" id="firstalternative" required>     </p>     <p>         <h3>réponse 2 </h3><input style="height:50px;font-size:14pt;" size="50" type="text" id="secondalternative" required>     </p>     <p>         <input id="buttonquestion" class="btn-success btn" style="height:50px;font-size:14pt;" type="submit" value=" créer la question " />     </p> </form> 

i have error 405 (not allowed). not success in ajax, error...


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -