function save_circuit(yaml){

    let xmlHttpReq = new XMLHttpRequest();

    xmlHttpReq.timeout = 10000;
    xmlHttpReq.ontimeout = function () {
        alert("For some reason saving the circuit has failed, please try again.");
    };

    xmlHttpReq.onerror = function () {
      alert("For some reason saving the circuit has failed, please try again.");
    };

    let url = '/projects/circuits-api/?circuitid='.concat(window.circuitId);
    xmlHttpReq.open( "POST", url, true);

    let authToken = getCookie('auth-token');
    xmlHttpReq.setRequestHeader('Authorization', authToken);
    let csrfToken = getCookie('csrftoken');
    xmlHttpReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    let data = `yaml-code=${encodeURI(yaml)}&csrfmiddlewaretoken=${csrfToken}`;

    xmlHttpReq.send(data);    
  }
/* use Django REST API to save circuit */
use Django REST API to save circuit
use Django REST API to save circuit
function save_circuit(yaml){
    let xmlHttpReq = new XMLHttpRequest();
    xmlHttpReq.timeout = 10000;
    xmlHttpReq.ontimeout = function () {
        alert("For some reason saving the circuit has failed, please try again.");
    };
    xmlHttpReq.onerror = function () {
      alert("For some reason saving the circuit has failed, please try again.");
    };
    let url = '/projects/circuits-api/?circuitid='.concat(window.circuitId);
    xmlHttpReq.open( "POST", url, true);
    let authToken = getCookie('auth-token');
    xmlHttpReq.setRequestHeader('Authorization', authToken);
    let csrfToken = getCookie('csrftoken');
    xmlHttpReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    let data = `yaml-code=${encodeURI(yaml)}&csrfmiddlewaretoken=${csrfToken}`;
    xmlHttpReq.send(data);    
  }
function save_circuit ( yaml ) { let xmlHttpReq = new XMLHttpRequest ( ) ; xmlHttpReq . timeout = 10000 ; xmlHttpReq . ontimeout = function ( ) { alert ( "For some reason saving the circuit has failed, please try again." ) ; } ; xmlHttpReq . onerror = function ( ) { alert ( "For some reason saving the circuit has failed, please try again." ) ; } ; let url = '/projects/circuits-api/?circuitid=' . concat ( window . circuitId ) ; xmlHttpReq . open ( "POST" , url , true ) ; let authToken = getCookie ( 'auth-token' ) ; xmlHttpReq . setRequestHeader ( 'Authorization' , authToken ) ; let csrfToken = getCookie ( 'csrftoken' ) ; xmlHttpReq . setRequestHeader ( 'Content-type' , 'application/x-www-form-urlencoded' ) ; let data = ` ${ encodeURI ( yaml ) } ${ csrfToken } ` ; xmlHttpReq . send ( data ) ; }
use Django REST API to save circuit
use Django REST API to save circuit