“Ajax Post” Kod odpowiedzi

Przykład JQuery Post

<script type="text/javascript">
    function send() {
        var person = {
            name: $("#id-name").val(),
            address:$("#id-address").val(),
            phone:$("#id-phone").val()
        }

        $('#target').html('sending..');

        $.ajax({
            url: '/test/PersonSubmit',
            type: 'post',
            dataType: 'json',
            contentType: 'application/json',
            success: function (data) {
                $('#target').html(data.msg);
            },
            data: JSON.stringify(person)
        });
    }
</script>
Annoying Ape

Ajax Post Call

<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

JQuery Post

$.post( "test.php", { name: "John", time: "2pm" })
  .done(function( data ) {
    alert( "Data Loaded: " + data );
  });
Glamorous Goat

Zrób żądanie 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

Metoda Ajax Post

function addtofav(e, id) {
            $.ajax({
                url: '@Url.Action("Action_Name", "Controller_Name")',
                type: 'POST',
                data: { Id: id }
            }).done(function () {
                swal('', 'Success_Message!', 'success');
            }).fail(function () {
                swal('', 'Failed_Message!', 'warning');
            })
        }
Said HR

Odpowiedzi podobne do “Ajax Post”

Pytania podobne do “Ajax Post”

Więcej pokrewnych odpowiedzi na “Ajax Post” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu