“AJAX POST SOLIT JavaScript” Código de respuesta

AJAX POST CALLE

<script>window.onload = function(){
    let aData = {"profile": "developer", "to": "[email protected]"};
	console.log(FormData);
    $.ajax({
        type: "POST",
        url: "/api/saveProfile",
        data: JSON.stringify(aData),
        contentType: "application/json",  
            success: function(){
               alert("Request was successful");
            }
        });
};
Defeated Dormouse

AJAX DATA POST LLAME en JavaScript

$.ajax({
   url: 'ajaxfile.php',
   type: 'post',
   data: {name:'yogesh',salary: 35000,email: '[email protected]'},
   success: function(response){

   }
});
Tame Teira

hacer una solicitud de AJAX Post jQuery

$.ajax({
  method: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
})

Better Bison

AJAX POST

var myKeyVals = { A1984 : 1, A9873 : 5, A1674 : 2, A8724 : 1, A3574 : 3, A1165 : 5 }



var saveData = $.ajax({
      type: 'POST',
      url: "someaction.do?action=saveData",
      data: myKeyVals,
      dataType: "text",
      success: function(resultData) { alert("Save Complete") }
});
saveData.error(function() { alert("Something went wrong"); });
Proud Pintail

JavaScript Enviar datos de publicación con AJAX

function makeRequest (method, url, data) {
  return new Promise(function (resolve, reject) {
    var xhr = new XMLHttpRequest();
    xhr.open(method, url);
    xhr.onload = function () {
      if (this.status >= 200 && this.status < 300) {
        resolve(xhr.response);
      } else {
        reject({
          status: this.status,
          statusText: xhr.statusText
        });
      }
    };
    xhr.onerror = function () {
      reject({
        status: this.status,
        statusText: xhr.statusText
      });
    };
    if(method=="POST" && data){
        xhr.send(data);
    }else{
        xhr.send();
    }
  });
}

//POST example
var data={"person":"john","balance":1.23};
makeRequest('POST', "https://www.codegrepper.com/endpoint.php?param1=yoyoma",data).then(function(data){
              var results=JSON.parse(data);
});
Grepper

AJAX POST SOLIT JavaScript

function myFunction()
{
    var elements = document.getElementsByClassName("formVal");
    var formData = new FormData(); 
    for(var i=0; i<elements.length; i++)
    {
        formData.append(elements[i].name, elements[i].value);
    }
    var xmlHttp = new XMLHttpRequest();
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
            {
                alert(xmlHttp.responseText);
            }
        }
        xmlHttp.open("post", "server.php"); 
        xmlHttp.send(formData); 
}
Indian Gooner

Respuestas similares a “AJAX POST SOLIT JavaScript”

Preguntas similares a “AJAX POST SOLIT JavaScript”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código