Answers for "ajax jquery response"

0

jquery ajax responseText

// To get jquery AJAX calls working
// remember to add Jquery to your head tag:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

var response = null;
var responseTextValue = null;

$.ajax({
	type: "GET",   
	url: "<Your url text>",   
	async: false,
	success : function(data) {
		// Here you can specify that you need some exact value like responseText
		responseTextValue = data.responseText;
	    response = data;
	}
});
Posted by: Guest on September-29-2020
1

jquery ajax request

// Using the core $.ajax() method
$.ajax({
 
    // The URL for the request
    url: "post.php",
 
    // The data to send (will be converted to a query string)
    data: {
        id: 123
    },
 
    // Whether this is a POST or GET request
    type: "GET",
 
    // The type of data we expect back
    dataType : "json",
})
  // Code to run if the request succeeds (is done);
  // The response is passed to the function
  .done(function( json ) {
     $( "<h1>" ).text( json.title ).appendTo( "body" );
     $( "<div class=\"content\">").html( json.html ).appendTo( "body" );
  })
  // Code to run if the request fails; the raw request and
  // status codes are passed to the function
  .fail(function( xhr, status, errorThrown ) {
    alert( "Sorry, there was a problem!" );
    console.log( "Error: " + errorThrown );
    console.log( "Status: " + status );
    console.dir( xhr );
  })
  // Code to run regardless of success or failure;
  .always(function( xhr, status ) {
    alert( "The request is complete!" );
  });
Posted by: Guest on September-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language