Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

326
Vistas
I have a SSJS code and AJAX, now how can I put all together?

I have a ssjs code that creates a data extension

 var DE = "MyDataExtension"
 Platform.Load("core","1.1") 

    var obj = {
        "CustomerKey" : 123,
        "Name" : DE,
        "Fields" : [
            { "Name" : "Id", "FieldType" : "Number", "IsPrimaryKey" : true, "IsRequired" : true },
            { "Name" : "MyData", "FieldType" : "Text", "MaxLength" : 50 },
            { "Name" : "Active", "FieldType" : "Boolean", "DefaultValue" : true }
        ]
    }

}
 }

And I found that to use this ssjs code in onclick function I must use AJAX, so I did it

  <script>
     
       
     function ajax() {
     var xmlHttp;
     if(window.XMLHttpRequest){
       xmlHttp = new XMLHttpRequest;
     } else {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     }
    
 
  xmlHttp.onreadystatechange = function() {
  if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
  console.log(xmlHttp.responseText);}}
  xmlHttp.open('POST','https://...', true);
   xmlHttp.send()}  
  
  </script> 
  
  

Now, how should I put all together ?

What i tried ->

      <script>
    function ajax() {
     var xmlHttp;
     if(window.XMLHttpRequest){
       xmlHttp = new XMLHttpRequest;
     } else {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
     
       
  xmlHttp.onreadystatechange = function() {
  if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
  console.log(xmlHttp.responseText);}}
  xmlHttp.open('POST','https://someone.com/LP', true);}


xmlHttp.send()}

</script> <script>
     function create(){
   var DE = "MyDE"


    var obj = {
        "CustomerKey" : 123,
        "Name" : DE,
        "Fields" : [
            { "Name" : "Id", "FieldType" : "Number", "IsPrimaryKey" : true, "IsRequired" : true },
            { "Name" : "MyData", "FieldType" : "Text", "MaxLength" : 50 },
            { "Name" : "Active", "FieldType" : "Boolean", "DefaultValue" : true }
        ]
    }


 };
  
  </script> 
  <button onclick="create();ajax()">
    Request 
     </button>
  

it's possible ? The code above it's not working, just nothing happens.

My goal is, when a button is clicked, a Data Extension is create, Thanks in advance!!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda