我正在发送一个AJAX请求,并希望用它发送URL变量的数据。我尝试过使用PHP的GET
,但是没有发送。
$.ajax({
type: "POST",
url: "send.php",
data: "name=" + "<?php $_GET['name']; ?>",
success: function(data) {
$("#div").html(data);
}
})
答案 0 :(得分:4)
你需要echo
获取变量。
$.ajax({
type: "POST",
url: "send.php",
data: "name=" + "<?php echo $_GET['name']; ?>",
success: function(data) {
$("#div").html(data());
}
})
此外,它更喜欢使用该对象发送数据。
$.ajax({
type: "POST",
url: "send.php",
data: {'name':'<?php echo $_GET['name']; ?>'},
success: function(data) {
$("#div").html(data());
}
})
答案 1 :(得分:3)
有两件事。
$.ajax({
type: "POST",
url: "send.php",
data: "name=" + <?php echo $_GET['name']; ?>,
success: function(data) {
$("#div").html(data());
}
});
首先是<?php echo $_GET['name']; ?>
。
其次是缺少右括号$("#div").html(data());
希望这会对你有所帮助。
答案 2 :(得分:1)
mGoogleApiClient = buildGoogleAPIClient();
gPlusLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
processGPlusSignIn();
}
});
private void processGPlusSignIn() {
if (!mGoogleApiClient.isConnecting()) {
Log.e("", "GPLUS area 111");
startExecutingGPlusLoginProcess();
mSignInClicked = true;
}
}
private void startExecutingGPlusLoginProcess() {
if (mConnectionResult != null && mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
Log.i("Registration", "Starting...");
mConnectionResult.startResolutionForResult(this, GPLUS_SIGN_IN_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
Log.e("Registartion", "Exception***" + e);
mIntentInProgress = false;
mGoogleApiClient.connect();
}
}
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.e(TAG,"onConnectionFailed called");
if (!connectionResult.hasResolution()) {
GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, ERROR_DIALOG_REQUEST_CODE).show();
return;
}
if (!mIntentInProgress) {
mConnectionResult = connectionResult;
Log.e("Registration", "Result?***" + connectionResult);
if (mSignInClicked) {
startExecutingGPlusLoginProcess();
}
}
}