我正在尝试将表单发布到PHP脚本,并且它一直无法将请求验证为POST请求,因此它从PHP脚本退出。 AJAX请求返回成功,但是从数据库返回的数据表明将请求识别为POST失败。我尝试更改内容类型等,但无济于事。
JS:
$(document).ready(function() {
$("#delete4").on('click', function(e) {
e.preventDefault();
var ok = confirm('Are you sure you want to delete this?');
if (ok == true)
{
console.log("true")
var data = $("#form4").serialize();
$.ajax({
data: data,
type: "post",
url: "delete_AJAX.php",
success: function(data) {
console.log("successfully deleted");
console.log(data);
//$("#div4").remove();
},
error: function(data) {
alert("fail");
console.log(data);
}
});
} else {
return;
}
});
});
HTML:
<form type="text" name="form4" id="form4" action="delete_AJAX.php" method="post">
<div class="aligner">
<button type="button" class="button_div" name="edit" onclick="send(52)">Edit</button>
<button type="button" class="button_div" id="delete4">Delete</button>
<button type="button" class="button_div" name="read" onclick="send2(52, 13)">See</button>
</div><br>
<input type="hidden" id="hidden_c4" value="13" name="hidden_c">
<input type="hidden" id="hidden_bid4" name="hidden_bid" value="52">
</form>
PHP:
require_once("db.php");
if ($_REQUEST['REQUEST_METHOD'] === 'POST')
{
$bid = $_POST['hidden_bid'];
echo "passed request";
$sql = "SELECT * FROM xxx WHERE yyy = $bid";
$result = mysqli_query($connection, $sql);
if ($result === false)
{
die("f1");
}
$resultCheck = mysqli_num_rows($result);
if (!resultCheck > 0)
{
echo "ERROR NO RESULT";
exit();
};
$row = mysqli_fetch_assoc($result);
$delete_cover = $row['cover'];
unlink($delete_cover);
// updating table row
$sql2 = "DELETE FROM xxx WHERE (yyy=?);";
$stmt = mysqli_stmt_init($connection);
if (!mysqli_stmt_prepare($stmt, $sql2))
{
header("Location: ../create.php?error&prepare1111");
exit();
}
else
{
$stmt->bind_param("i", $bid);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
$connection->close();
echo "successfully deleted";
}
} else {
echo "FAILURE TO REQUEST";
}
因此,我一直不断出现失败“ FAILURE TO REQUEST”,并且当我删除脚本的任何障碍时,post显示为空,并且变量arent设置。因此,它在“ f1”错误处停止。任何帮助都将是惊人的!谢谢!
答案 0 :(得分:2)
您似乎为“ REQUEST_METHOD”使用了错误的全局变量。
代替OpenFileDialog
使用FileDialog
答案 1 :(得分:2)
在有条件的情况下,
pod spec lint --verbose
应该替换为 RandomGenerator (2.0.0) - Analyzing on iOS 12.0 platform.
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-App`: (``)
Fetching external sources
-> Fetching podspec for `RandomGenerator` from `/Users/elitia/Desktop/Elitia/Hacker/swift/RandomGenerator/RandomGenerator/RandomGenerator.podspec`
Resolving dependencies of
Comparing resolved specification to the sandbox manifest
A RandomGenerator
Downloading dependencies
-> Installing RandomGenerator (2.0.0)
> Copying RandomGenerator from `/Users/elitia/Library/Caches/CocoaPods/Pods/External/RandomGenerator/24fbdd7e610122190d368443f1e96b67-ef799` to
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/RandomGenerator`
- Running pre install hooks
Generating Pods project
- Creating Pods project
- Installing files into Pods project
- Adding source files
- Adding frameworks
- Adding libraries
- Adding resources
- Linking headers
- Installing Pod Targets
- Installing target `RandomGenerator` iOS 12.0
- Generating module map file at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/RandomGenerator/RandomGenerator.modulemap`
- Generating umbrella header at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/RandomGenerator/RandomGenerator-umbrella.h`
- Generating Info.plist file at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/RandomGenerator/RandomGenerator-Info.plist`
- Generating dummy source at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/RandomGenerator/RandomGenerator-dummy.m`
- Installing Aggregate Targets
- Installing target `Pods-App` iOS 12.0
- Generating Info.plist file at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/Pods-App/Pods-App-Info.plist`
- Generating module map file at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/Pods-App/Pods-App.modulemap`
- Generating umbrella header at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/Pods-App/Pods-App-umbrella.h`
- Generating dummy source at
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support
Files/Pods-App/Pods-App-dummy.m`
- Stabilizing target UUIDs
- Running post install hooks
- Writing Xcode project file to
`../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Pods.xcodeproj`
Cleaning up sandbox directory
- Writing Lockfile in `../../../../../../../../var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Podfile.lock`
- Writing Manifest in `../../../../../../../../private/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Manifest.lock`
Integrating client project
[!] Please close any current Xcode sessions and use `App.xcworkspace` for this project from now on.
Integrating target `Pods-App` (`../../../../../../../../var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/App.xcodeproj` project)
Adding Build Phase '[CP] Embed Pods Frameworks' to project.
Adding Build Phase '[CP] Check Pods Manifest.lock' to project.
-> Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
Building with `xcodebuild`.
$ /usr/bin/xcodebuild clean build -workspace /var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/App.xcworkspace -scheme App
-configuration Release CODE_SIGN_IDENTITY=- -sdk iphonesimulator -destination id=C1A6D42E-F49B-43EF-B367-B698E97A422A
Build settings from command line:
CODE_SIGN_IDENTITY = -
SDKROOT = iphonesimulator12.2
note: Using new build system
** CLEAN SUCCEEDED **
note: Using new build system
note: Planning build
note: Constructing build description
Build system information
warning: no rule to process file '/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/RandomGenerator/RandomGenerator/RandomGenerator.xcodeproj/project.xcworkspace/contents.xcworkspacedata' of type 'text.xml' for architecture 'x86_64' (in target 'RandomGenerator')
Build system information
warning: no rule to process file '/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/RandomGenerator/RandomGenerator/Podfile' of type 'text' for architecture 'x86_64' (in target 'RandomGenerator')
Build system information
warning: no rule to process file '/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/RandomGenerator/RandomGenerator/RandomGenerator.xcodeproj/project.pbxproj' of type 'text.pbxproject' for architecture 'x86_64' (in target 'RandomGenerator')
Build system information
warning: no rule to process file '/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/RandomGenerator/RandomGenerator/RandomGenerator.podspec' of type 'text' for architecture 'x86_64' (in target 'RandomGenerator')
Build system information
warning: duplicate output file '/Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist' on task: ProcessInfoPlistFile /Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist /var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/Target Support Files/RandomGenerator/RandomGenerator-Info.plist (in target 'RandomGenerator')
Build system information
error: Multiple commands produce '/Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist':
1) Target 'RandomGenerator' (project 'Pods') has copy command from '/var/folders/zc/rtmmz52s03q3pl4vgb06psy00000gn/T/CocoaPods-Lint-20190703-3687-1fmtamf-RandomGenerator/Pods/RandomGenerator/RandomGenerator/RandomGenerator/Info.plist' to '/Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist'
2) Target 'RandomGenerator' (project 'Pods') has process command with output '/Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist'
** BUILD FAILED **
Testing with `xcodebuild`.
-> RandomGenerator (2.0.0)
- WARN | [iOS] license: Unable to find a license file
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: no rule to process file 'RandomGenerator/RandomGenerator/RandomGenerator.xcodeproj/project.xcworkspace/contents.xcworkspacedata' of type 'text.xml' for architecture 'x86_64' (in target 'RandomGenerator')
- NOTE | [iOS] xcodebuild: warning: no rule to process file 'RandomGenerator/RandomGenerator/Podfile' of type 'text' for architecture 'x86_64' (in target 'RandomGenerator')
- NOTE | [iOS] xcodebuild: warning: no rule to process file 'RandomGenerator/RandomGenerator/RandomGenerator.xcodeproj/project.pbxproj' of type 'text.pbxproject' for architecture 'x86_64' (in target 'RandomGenerator')
- NOTE | [iOS] xcodebuild: warning: no rule to process file 'RandomGenerator/RandomGenerator/RandomGenerator.podspec' of type 'text' for architecture 'x86_64' (in target 'RandomGenerator')
- NOTE | [iOS] xcodebuild: warning: duplicate output file '/Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist' on task: ProcessInfoPlistFile /Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist Target Support Files/RandomGenerator/RandomGenerator-Info.plist (in target 'RandomGenerator')
- NOTE | [iOS] xcodebuild: error: Multiple commands produce '/Users/elitia/Library/Developer/Xcode/DerivedData/App-akwujhxkudfgkodyxpqvnonnahsn/Build/Products/Release-iphonesimulator/RandomGenerator/RandomGenerator.framework/Info.plist':
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error and 1 warning.
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.1/lib/cocoapods/command/spec/lint.rb:94:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.7.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
。
答案 2 :(得分:1)
也许有帮助
if( $_POST ) {
echo 'posted';
//do some stuff
}