How does PHP receive javascriptPOST data?

Source: Internet
Author: User
How does PHP receive javascriptPOST data? $ (Document ). ready (function () & nbsp ;{& nbsp; & nbsp ;$ (# submit ). click (function () {username & nbsp; 1233; password & nbsp; 1233; valc & PHP how to receive javascript POST data?
$(document).ready(function() {
$("#submit").click(function(){
username = 1233;
password = 1233;
valc = 1233;
//password = hex_md5(hex_md5(password)+valc);
//password = hex_md5(password + valc);
var data = new Object();
data.j_username=username;
data.j_password=password;
data.j_valcode=valc;
alert(password);
$.ajax({
url : 'http://127.0.0.1/test/simulation.php',
type : "post",
dataType : "jsonp",
jsonp : "jsonp",
data:data,
})
})
});

In the above jsp code, post should be in the jsonp format. how can I receive and print these values in php?
The code has been modified to facilitate debugging ~
There is another problem... changing the URL without changing the code
Why is the POST data different when it is changed to an incorrect URL or a correct URL?
Correct:

Incorrect:

Please also explain

------ Solution --------------------
Jsonp is the returned format, not the previous data format of Post. Jsonp is used only for cross-origin requests.
The same is true for how PHP receives Post data from other pages.
------ Solution --------------------
Rather than accepting data, you cannot see the content printed by php.

$.ajax({
url : './simulation.php',
type : "post",
dataType : "jsonp",
jsonp : "jsonp",
data:data,
})
Rewrite
         $.ajax({
url : './simulation.php',
type : "post",
data:data,
success : function(d) {
alert(d);
}
})

In simulation. php
Print_r ($ _ POST );
You can see what is passed in.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.