簡體   English   中英

Ajax GET Request inside ajax post 請求?

[英]Ajax GET Request inside ajax post request?

是否可以在另一個 ajax 請求中發出 ajax 請求? 因為我需要來自第一個 ajax 請求的一些數據來發出下一個 ajax 請求。

我試圖制作一個腳本,但我看到我的請求不是 GET,而是 POST,我不知道問題出在哪里..

 <script type="text/javascript"> $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $('#file-upload').submit(function(e) { e.preventDefault(); let formData = new FormData(this); $('#file-input-error').text(''); $.ajax({ type: 'POST', url: "{{ route('resume.store') }}", data: formData, contentType: false, processData: false, success: (response) => { if (response) { this.reset(); $("#showResponseArea span").html(response); //you will paste your response msg to the $.ajax({ type: 'GET', url: "{{ route('resume.api') }}", dataType: 'json', data: { 'url': response, } }) } }, error: function(response) { $('#file-input-error').text(response.responseJSON.message); } }); }); </script>

我的代碼完美運行,真正的問題出在 controller,而不是:

public function fetch(Request $request)
{
    $cvupload = $request->url;
    $client = new Client();
    $res = $client->get("https://api.apilayer.com/resume_parser/url?url=$cvupload", [
        'headers' => [
            'apiKey' => 'xxx'
        ]
    ]);

我的代碼是$res = $client->post

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM