Step 1. It is the best and most effective way when need to return multiple values as a response from the PHP script to the jQuery. Then we pass in some data to send along with the request (name and city). The third parameter is a callback function. All properties except for url are optional. GET has limitation on the query string value. AJAX is about exchanging data with a server, without reloading the whole page. How do I pass have a Javascript script request a PHP page and pass data to it? If you are passing a a lot of data (complex object), It might be a good idea to convert your action method to a HttpPost action method and use jQuery post to post data to that. Data to be sent to the server. Don't use a JQuery AJAX method, use $("#myForm").submit().The form- which will be invisible, and only used to submit values from your client side code, not user input- will never be shown nor otherwise used, and the page will be Ajax According to the service definition, it's expecting JSON as the request format, but you're passing a form encoded key/value pair. send data Don't use a JQuery AJAX method, use $("#myForm").submit().The form- which will be invisible, and only used to submit values from your client side code, not user input- will never be shown nor otherwise used, and the page will be Most properties from the original event are copied over and normalized to the new event object. It is also passed the text status of the response. Python Flask First we can store the data we want to pass back to the server in an array. In this post, we'll examine each of the above methods, and see the pros and cons of each, as well as how to implement them. Using JQuery, AJAX The form can be invisible. Data to be sent to the server. In the following block, "data" automatically passes the values in the querystring. Event View live demo and download source code. You can see it demonstrates how to add a custom field to the form with fd.append() as well as how to handle response data when the ajax request is done. All properties except for url are optional. A default can be set for any option with $.ajaxSetup(). Here's what works for me after 2 days of head-scratching; why I couldn't get the AJaX 'data' setting to send two key/values (including a variable containing raw image data) was a mystery, but that seems to be what the jQuery.param() function was written for; create a params array with your variables, without quotes: For remote data sources only, Select2 does not create a new