xmlhttprequest 相关问题

XMLHttpRequest(XHR)是一个JavaScript对象,它公开了一个API,用于从运行Web浏览器的前端代码发出异步HTTP请求 - 也就是说,用于启用称为AJAX的编程技术。 XHR API是遗留API。它已被Fetch API取代。

JSP中无法从ajax请求获取表单参数

我在 html 页面中有以下 JavaScript 函数,该函数将两个参数发送到 JSP 页面。我尝试通过发出 GET 请求来发送参数,并且能够在 JSP 中接收它们。但当我

回答 1 投票 0

如何将值从 Outlook VBA 表单传递到 asmx Web 服务?

我正在尝试将文本框值从 Outlook 用户表单传递到 asmx Web 服务。我已经使用 PHP 成功完成了此操作,但现在需要使用 VBA 来完成此操作。目前该表格对

回答 1 投票 0

Fetch API,给我index.html,但没有给我react JS中UI的dom结构

我在reactjs上构建了一个应用程序并在内部托管,当我执行fetch API或xhr时,我只获得公共文件夹中的index.html,并且它以id = root结尾。然而它并没有给我...

回答 1 投票 0

为什么我的XHR的statusText是空的?

当我在生产系统上执行 XHR 时,响应中的 statusText 将是一个空字符串。但是,在我们的开发系统上,statusText 将正确反映状态。 雅阁...

回答 3 投票 0

了解 Ajax 请求需要多长时间才能完成

有什么好方法可以找出特定 $.ajax() 请求花费了多长时间? 我想获取此信息,然后将其显示在页面上的某个位置。 回答??:::: 我是 JavaScript 新手,...

回答 10 投票 0

PHP显示XMLHttpRequest发送的POST数据不存在?

我目前正在尝试在 XAMPP 上创建一个注册页面。我的系统的总结是,当用户单击提交按钮时,JS 通过 POST 对 php 文件执行 xmlhttprequest,上传用户的数据...

回答 1 投票 0

从源“http://localhost:5173”访问“...”处的 XMLHttpRequest 已被 CORS 策略阻止

我正在使用 MERN 堆栈开发一个应用程序,使用reactjs作为前端,nodejs作为后端。我已经开发了后端代码并使用邮递员进行了测试,但是在来回访问登录和其他API时...

回答 1 投票 0

PHP-Laravel Amazon feed XML 解析第 1 行第 1 列发生致命错误

1.02 <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.02</DocumentVersion> <MerchantIdentifier>MYMERCHANT123</MerchantIdentifier> </Header> <MessageType>ProcessingReport</MessageType> <Message> <MessageID>1</MessageID> <ProcessingReport> <DocumentTransactionID>172210019669</DocumentTransactionID> <StatusCode>Complete</StatusCode> <ProcessingSummary> <MessagesProcessed>0</MessagesProcessed> <MessagesSuccessful>0</MessagesSuccessful> <MessagesWithError>1</MessagesWithError> <MessagesWithWarning>0</MessagesWithWarning> </ProcessingSummary> <Result> <MessageID>0</MessageID> <ResultCode>Error</ResultCode> <ResultMessageCode>5001</ResultMessageCode> <ResultDescription>XML Parsing Fatal Error at Line 1, Column 1: Content is not allowed in prolog. Content is not allowed in prolog.</ResultDescription> </Result> </ProcessingReport> </Message> </AmazonEnvelope> 这是我的错误,这是我的代码: $requestXml = '<?xml version="1.0" encoding="utf-8"?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>MYMERCHANT123</MerchantIdentifier> </Header> <MessageType>Product</MessageType> <PurgeAndReplace>false</PurgeAndReplace> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Product> <SKU>56789</SKU> <StandardProductID> <Type>ASIN</Type> <Value>B0EXAMPLEG</Value> </StandardProductID> <ProductTaxCode>A_GEN_NOTAX</ProductTaxCode> <DescriptionData> <Title>Example Product Title</Title> <Brand>Example Product Brand</Brand> <Description>This is an example product description.</Description> <BulletPoint>Example Bullet Point 1</BulletPoint> <BulletPoint>Example Bullet Point 2</BulletPoint> <MSRP currency="USD">25.19</MSRP> <Manufacturer>Example Product Manufacturer</Manufacturer> <ItemType>example-item-type</ItemType> </DescriptionData> <ProductData> <Health> <ProductType> <HealthMisc> <Ingredients>Example Ingredients</Ingredients> <Directions>Example Directions</Directions> </HealthMisc> </ProductType> </Health> </ProductData> </Product> </Message> </AmazonEnvelope>'; // $requestXml = trim($requestXml); // doesn't help // $requestXml = preg_replace('/[[:^print:]]/', '', $requestXml); // $requestXml = preg_replace('/^(\xEF\xBB\xBF)/', '', $requestXml); $response = Http::withHeaders([ 'Content-Type' => 'text/xml; charset=utf-8' ])->put($url, [ 'body' => $requestXml ]); 我希望有人可以帮助我,因为我快疯了,因为几天后我无法解决这个问题,但这很重要。 我尝试了在互联网上找到的所有内容,阅读了 Stackoverflow 上的所有内容,但没有解决我的问题。 我还尝试从文件中调用它(我通过 Notepad++ 将其保存为 UTF-8) $prefixAmazon = Storage::disk('amazon')->getDriver()->getAdapter()->getPathPrefix(); $requestXml = file_get_contents($prefixAmazon . 'createFeed.xml'); 我找到了使用 Amazon SP-API 在 Laravel 中创建产品源的解决方案 (https://github.com/amazon-php/sp-api-sdk): composer require amazon-php/sp-api-sdk composer require nyholm/psr7 -W use AmazonPHP\SellingPartner\AccessToken; use AmazonPHP\SellingPartner\Model\Feeds\CreateFeedDocumentSpecification; use AmazonPHP\SellingPartner\Model\Feeds\CreateFeedSpecification; use AmazonPHP\SellingPartner\Regions; use AmazonPHP\SellingPartner\SellingPartnerSDK; use App\Models\Amazon\AmazonAuth; use Exception; use GuzzleHttp\Handler\CurlFactory; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\App; use Carbon\Carbon; use Illuminate\Support\Facades\Storage; use GuzzleHttp\Client; use AmazonPHP\SellingPartner\Api\FeedsApi\FeedsSDK; use AmazonPHP\SellingPartner\Configuration; use AmazonPHP\SellingPartner\Exception\ApiException; use AmazonPHP\SellingPartner\Exception\InvalidArgumentException; use AmazonPHP\SellingPartner\HttpFactory; use AmazonPHP\SellingPartner\HttpSignatureHeaders; use AmazonPHP\SellingPartner\ObjectSerializer; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Log\LoggerInterface; use AmazonPHP\SellingPartner\OAuth; use Buzz\Client\Curl; use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Log\NullLogger; public function getAccessToken($channelId) { $amazonAuth = AmazonAuth::where('channel_id', $channelId)->first(); //my local database channel $isExpired = Carbon::parse($amazonAuth->expires_at)->isPast(); $token = null; if ($isExpired) { $data = [ 'grant_type' => 'refresh_token', 'refresh_token' => $amazonAuth->refresh_token, 'client_id' => TenantService::getLwaClientId(), 'client_secret' => TenantService::getLwaSecret() ]; $response = Http::asForm()->post( 'https://api.amazon.com/auth/o2/token', $data ); if ($response->successful()) { $body = $response->json(); $amazonAuth->access_token = $body['access_token']; $amazonAuth->expires_at = now()->addSeconds($body['expires_in'])->toDateTimeString(); $amazonAuth->save(); $token = $body['access_token']; } else { Log::channel('amazon')->info('Amazon access token refresh failed for amazon auth id: ' . $amazonAuth->id); } } else { $token = $amazonAuth->access_token; } if ($token) { $accessToken = new AccessToken( $token, $amazonAuth->refresh_token, 'refresh_token', (int) $amazonAuth->expires_in, 'refresh_token' ); return $accessToken; } } public function createFeedTest() { $client = new Client(); $factory = new Psr17Factory(); // $httpFactory = new HttpFactory($factory, $factory); $region = 'eu'; $accessToken = $this->getAccessToken(150); $logger = new NullLogger(); $configuration = Configuration::forIAMUser( $getLwaClientId, $getLwaSecret, $getAwsAccessKey, $getAwsSecretKey, ); $sdk = SellingPartnerSDK::create($client, $factory, $factory, $configuration, $logger); $region = Regions::EUROPE; $specification = new CreateFeedDocumentSpecification; $feedDoc = $sdk->feeds()->createFeedDocument( $accessToken, $region, $specification->setContentType('text/xml; charset=utf-8') ); $feedDocID = $feedDoc['feed_document_id']; $urlFeedUpload = $feedDoc['url']; $fileContent = '<?xml version="1.0" encoding="utf-8" ?> <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>MYMERCHANTTOKEN</MerchantIdentifier> </Header> <MessageType>Product</MessageType> <PurgeAndReplace>false</PurgeAndReplace> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Product> <SKU>56789</SKU> <StandardProductID> <Type>ASIN</Type> <Value>B0EXAMPLEG</Value> </StandardProductID> <ProductTaxCode>A_GEN_NOTAX</ProductTaxCode> <DescriptionData> <Title>Example Product Title</Title> <Brand>Example Product Brand</Brand> <Description>This is an example product description.</Description> <BulletPoint>Example Bullet Point 1</BulletPoint> <BulletPoint>Example Bullet Point 2</BulletPoint> <MSRP currency="USD">25.19</MSRP> <Manufacturer>Example Product Manufacturer</Manufacturer> <ItemType>example-item-type</ItemType> <CountryOfOrigin>DE</CountryOfOrigin> <UnitCount>1</UnitCount> <PPUCountType>stück</PPUCountType> <IsExpirationDatedProduct>false</IsExpirationDatedProduct> </DescriptionData> <ProductData> <Health> <ProductType> <HealthMisc> <Ingredients>Example Ingredients</Ingredients> <Directions>Example Directions</Directions> </HealthMisc> </ProductType> </Health> </ProductData> <IsHeatSensitive>false</IsHeatSensitive> </Product> </Message> </AmazonEnvelope>'; dump($feedDoc); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $urlFeedUpload); curl_setopt($curl, CURLOPT_UPLOAD, true); curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8')); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_PUT, 1); curl_setopt($curl, CURLOPT_INFILE, fopen('data://text/plain,' . $fileContent, 'r')); curl_setopt($curl, CURLOPT_INFILESIZE, strlen($fileContent)); #Only use below option on TEST environment if you have a self-signed certificate!!! On production this can cause security issues curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); dump($response); curl_close($curl); $specificationNewFeed = new CreateFeedSpecification([ 'feed_type' => 'POST_PRODUCT_DATA', 'marketplace_ids' => ['A1PA6795UKMFR9'], 'input_feed_document_id' => $feedDocID ]); $responseFeed = $sdk->feeds()->createFeed( $accessToken, $region, $specificationNewFeed ); dd($responseFeed); }

回答 1 投票 0

“使用事件传递结果”是什么意思?

我在 mdn web 文档上阅读了有关 XMLHttpRequest 的发送方法的内容。 我无法理解“使用事件传递结果是什么意思” 如果请求是异步的(这是de...

回答 2 投票 0

SonarQube 如何使用 Web API 登录

我正在编写一个网络应用程序,可以显示来自 Sonarqube 的代码气味结果,但我也希望它有时可以创建自定义规则。目前,我可以使用

回答 2 投票 0

预检选项请求在浏览器中返回 403/forbidden 和不同的标头

我目前正在开发一个混合应用程序,该应用程序也应该稍后通过官方公司域在常规网络浏览器中运行。后端提供RESTful API,支持各种

回答 1 投票 0

浏览器如何知道何时重新加载以及何时在单页应用程序中调用 javascript 代码?

我正在学习 React,并且对单页应用程序等概念很陌生。 所以我从单页应用程序教程中了解到的是,只有所需的数据从服务器发送......

回答 2 投票 0

HTTP 表单元素与 Fetch 和 XMLHttpRequest

我目前正在学习 Web 开发并遇到了 HTTP。让我困惑的一件事是如何准确地发出 HTTP 请求。在视频中我观看了他们发送 HTTP 请求的主要方式...

回答 2 投票 0

XMLHttpRequest 已弃用。用什么代替?

尝试使用纯JS方法来检查我是否有有效的JS图像url。我收到一条警告,指出 XMLHttpRequest 已被弃用。有什么更好的方法来做到这一点? url存在(网址){ 常量 http...

回答 4 投票 0

通过JavaScript从REST API获取JSON数据显示部分数据

我正在尝试通过 JavaScript 从 alchemynewsapi 获取数据。我收到的样本数据是: { “状态”:“正常”, “总交易数”:“68”, “结果”...

回答 1 投票 0

Javascript/Ajax 中的 HTTP HEAD 请求?

是否可以在 JavaScript 中仅使用 XMLHTTPRequest 来执行 HTTP Head 请求? 我的动机是节省带宽。 如果不是,可以造假吗?

回答 3 投票 0

在Ubuntu上使用XMLHttpRequest()和Apache时如何在python中接收POST数据?不使用烧瓶

我真的很难从客户端 JavaScript 获取数据,使用 xmlHTTPrequest POST 到一个非常简单的 python3 cgi-bin 程序。我看到很多 Forms 和 Flask 的例子,但我真的......

回答 2 投票 0

从 React Native 将图像上传到 AWS 预签名 URL

我正在尝试将图像上传到AWS Presigned url。我可以获得预先签名的 url,然后我可以从 Postman 上传图像,但我尝试从 React Native 应用程序发送,仅发送 uri 信息(内容:/...

回答 1 投票 0

C++ HTTP 服务器文件下载器与 Ajax 上传器问题

出于某些原因和教育目的,我从头开始开发了一个 C++ HTTP 服务器,它应该使用 AJAX 处理动态请求从 HTML 页面捕获文件上传并将其保存在

回答 1 投票 0

可以从自定义应用程序发出禁止的标头请求吗?

我想我可以制作一个简单的网页,其中包含带有 URL 地址的文本输入 并使用 XMLHttpRequest 或 Fetch 将任何站点的数据获取到带有 id 的自定义 div 中。 这是我尝试的方法:0 ...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.