X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fstatic%2Funbound_reservation_static%2Fjs%2Fcreatepost_.js;fp=portal%2Fstatic%2Funbound_reservation_static%2Fjs%2Fcreatepost_.js;h=b19b5cd7b1456c465d3c13cfd336482cf2f282ca;hb=729a9dbb380b51a217194ba2a4e5978186fe50b0;hp=0000000000000000000000000000000000000000;hpb=c4bd5da6e2630eddf1262aa8d808dbb48b097d53;p=unfold.git
diff --git a/portal/static/unbound_reservation_static/js/createpost_.js b/portal/static/unbound_reservation_static/js/createpost_.js
new file mode 100644
index 00000000..b19b5cd7
--- /dev/null
+++ b/portal/static/unbound_reservation_static/js/createpost_.js
@@ -0,0 +1,120 @@
+$(function() {
+
+
+ // Submit post on submit
+ // $('#b1').bind('click', function(event){
+ // event.preventDefault();
+ // console.log("form submitted!") // sanity check
+ // create_post();
+ // });
+
+$('#b1').bind('click', function(event){
+ event.preventDefault();
+ console.log("form submitted!") // sanity check
+ jsondata=document.getElementById("jsondata").value;
+ create_post(jsondata);
+ });
+ // AJAX for posting
+ function create_post(jsondata) {
+ $("button").hide(300);
+ $("#but").show(6000);
+ $('#but').html(' loading...');
+ console.log("create post is working!")
+console.log(JSON.stringify(jsondata));
+var obj = jQuery.parseJSON(jsondata);
+console.log(JSON.stringify(obj));
+ // sanity check
+ var myEvent = {"resources":[{"type": "Node"},{"type": "Node"}]};
+ console.log(JSON.stringify(myEvent));
+ //jsondata=JSON.parse(JSON.parse(json).jsondata);
+ jsondata=jsondata.replace("\\", "");
+ console.log(jsondata);
+ $.ajax({
+ url : "create_post/", // the endpoint
+ type : "POST", // http method
+ data : JSON.stringify(obj), // data sent with the post request
+ // handle a successful response
+ complete:function(){
+ //alert("Request completed");
+ $("#but").hide();
+ $("button").show();
+ },
+ success : function(data,status) {
+
+ console.log(data,status); // log the returned json to the console
+
+ var obj = JSON.parse(data);
+ // alert(data);
+ for (var i = 0; i < obj.resource_response.resources.length; i++) {
+ var k=i+1;
+ var m='#'+k;
+ input_2 = " Node-"+k+""+
+ //"