
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
Send multiple data with ajax in PHP
Data can be sent through JSON or via normal POST. Following is an example showing data sent through JSON −
var value_1 = 1; var value_2 = 2; var value_3 = 3; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "your_url_goes_here", data: { data_1: value_1, data_2: value_2, data_3: value_3 }, success: function (result) { // perform operations here } });
With normal post, the below code can be used −
$.ajax({ type: "POST", url: $('form').attr("action"), data: $('#form0').serialize(), success: function (result) { // perform operations here } });
An alternate to the above code has been demonstrated below −
data:'id='+ID & 'user_id=' + USERID, with: data: {id:ID, user_id:USERID} so your code will look like this : $(document).ready(function(){ $(document).on('click','.show_more',function(){ var ID = 10; var USERID =1; $('.show_more').hide(); $('.loding').show(); $.ajax({ type:'POST', url:'/ajaxload.php', data: {id:ID, user_id:USERID}, success:function(html){ $('#show_more_main'+ID).remove(); $('.post_list').append(html); } }); }); });
- Related Articles
- How to use POST method to send data in jQuery Ajax?
- How to use GET method to send data in jQuery Ajax?
- How to send FormData objects with Ajax-requests in jQuery?
- How to send button value to PHP backend via POST using ajax?
- Send stdout to Multiple Commands
- Download file through an AJAX call in PHP
- PHP Exception Handling with Multiple catch blocks
- How to send data to previous activity in Android?
- How to send data through wifi in android programmatically?
- How to send data over remote method in java?
- How can I send radio button value in PHP using JavaScript?
- How can I filter JSON data with multiple objects?
- How to retrieve data from JSON file using jQuery and Ajax?
- PHP data://
- Send data from one Fragment to another using Kotlin?

Advertisements