Month: April 2019

jQuery.ajax() Method

jQuery.ajax() method performs asynchronous http request and gets the data from the server. it allows you to send asynchronous http requests to submit or retrieve data from the server without reloading the whole page.
it can be used to send http GET, POST, PUT, DELETE etc. request. It can retrieve any type of response from the server.

Syntax: jQuery.ajax(url,[options])

Use option parameter to customize ajax request as per your need. All available options for configuring Ajax request can be listed below.

  • accepts
  • async
  • beforeSend
  • cache
  • complete
  • contentType
  • crossDomain
  • data
  • dataType
  • error
  • global
  • headers
  • ifModified
  • isLocal
  • jsonp
  • jsonpCallback
  • mimeType
  • password
  • processData
  • statusCode
  • success
  • timeout
  • type
  • url
  • username
  • xhr
  • xhrFields

What is the difference between jQuery.get() and jQuery.ajax()?

jQuery.ajax() is the all-encompassing Ajax request method provided by jQuery. It allows for the creation of highly-customized Ajax requests, with options for how long to wait for a response, how to handle a failure, whether the request is blocking (synchronous) or non-blocking (asynchronous), what format to request for the response, and many more options.

jQuery.get() is a shortcut method that uses jQuery.ajax() under the hood, to create an Ajax request that is typical for simple retrieval of information. Other pre-built Ajax requests are provided by jQuery, such as jQuery.post(), jQuery.getScript(), and jQuery.getJSON().

How to disable comments in WordPress?

To disable comments in WordPress, Please follow below steps

Step 1: Login to your WordPress admin panel.
Step 2: Go to the Settings menu.
Step 3: Under Settings menu click on Discussion.
Step 4: Uncheck Allow people to post comments on new articles. checkbox
Step 5: Click on save changes button, you done

What is usermeta function in WordPress?

The usermeta function is used to retrieve the metadata of users. It can return a single value or an array of metadata.

Syntax is: get_user_meta( int $user_id, string $key = ”, bool $single = false )

User id is the required user id parameter

Key is the optional parameter which is the meta key to retrieve. By default, it returns data for all key values.

Single is an optional parameter that tells whether the single value will return. By default, it is false.