PHP and Ajax
How the Ajax call works:
• url – The external URL to which we are sending the request. In this case we are organized all Ajax PHP scripts into a folder/file.
• type – Type defines the request method, POST or GET.
• data – What content are we passing to the PHP file? It can be JSON object, string or array.
• datatype – Which type of data expected back from the server.
• async – By default, all requests are send asynchronously. Set it false to make asynchronous.
• username – Username to be used with XMLHttpRequest in response to an HTTP access authentication request.
• password – Password to used with XMLHttpRequest in response to an HTTP access authentication request.
• beforeSend – Callback function to be executed before Ajax request is send.
• complete – A callback function to be executed when request finishes.
• accept – The content type sent in the request header that tells the server what kind of response it will accept in return
• global – Boolean indicating wether to trigger a global ajax request handler not. Default is true.
• headers – Object of Additional key header key/value pair to send along with request.
• isLocal – Set this true if you want to recognize the current envoirnment as local.
• mimeType – String containing a mime type to override the XMLHttpRequest mime type.
• contentType – Containing a type of content when sending content to the server. Default is “application/x-www-form-urlencoded; charset=UTF-8”.
• processData – Indicating whether data assigned to data option will be converted to a query string. Default is true.
• statusCode – JSON object containing numeric HTTP codes and functions to be called when the response has the corresponding code.
• success – If the Ajax request runs successfully then we either call a separate function or write the callback inline. Usually write the function within Ajax because it’s often much easier.
• error – Ajax request fails, or gets an error in the response, this alternative function is triggered. Usually helpful when debugging issues between JS and PHP.
• timeout – Number value in milliseconds specifies a timeout for the request.