作者:U友50096631 | 来源:互联网 | 2023-07-08 14:51
Imtryingtosendssomedataalongwithaposttoaspecificurlwhichhasaphpscriptbehindit.
I'm trying to sends some data along with a post to a specific url which has a php script behind it. At this moment I don't have access to the php script. The php script checks if the string matches any record in the db and returns that record if there is a match. If there is no match the script will return all the records.
我正在尝试将一些数据和一个帖子发送到一个特定的URL,后面有一个php脚本。此刻我无法访问php脚本。 php脚本检查字符串是否与db中的任何记录匹配,如果匹配则返回该记录。如果没有匹配,脚本将返回所有记录。
The following code is what I have so far. As you can see I have a string named: shouldnotfindanyresultsstring. This should actually not return any results. However it returns all records instead of no records.
以下代码是我到目前为止的代码。如您所见,我有一个名为:shouldnotfindanyresultsstring的字符串。这实际上不应该返回任何结果。但是它返回所有记录而不是没有记录。
What I tried:
我尝试了什么:
- Use
params
instead of data
使用params而不是数据
- use different
Content-types
使用不同的内容类型
- use the short version of the post method
使用post方法的简短版本
$http({
url: $scope.url,
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: {search: "shouldnotfindanyresultsstring"}
}).then(function (response) {
console.log(response);
}, function (response) { // optional
console.log("Still not working");
});
So eventually I want to search records in the db with the search string. However I do not get it working.
所以最终我想用搜索字符串搜索数据库中的记录。但是,我没有让它工作。
With postman I can generate a post which works. I do have a strong feeling that it has something to do with the Content-type
有了邮递员,我可以生成一个有效的帖子。我确实感觉它与Content-type有关
3 个解决方案