[英]Ajax GET Request inside ajax post request?
Is it possible to make an ajax request inside another ajax request?是否可以在另一个 ajax 请求中发出 ajax 请求? because I need some data from first ajax request to make the next ajax request.
因为我需要来自第一个 ajax 请求的一些数据来发出下一个 ajax 请求。
I tried to make a script, but i see that instead of GET, my request is POST and i dont know where is the problem..我试图制作一个脚本,但我看到我的请求不是 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>
My code works perfectly, the real problem was in the controller, instead of:我的代码完美运行,真正的问题出在 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'
]
]);
my code was with $res = $client->post
.我的代码是
$res = $client->post
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.