How to incorporate a tag with a script for handling POST using AJAX on your site?

Good afternoon. There is a website sarrcoko.ru/ogeresult - access to it is not. On your website place a block?
c15c5fa321.png
<section id="user">
 the <h3>RESULTS of OGE/GVA</h3>
 <div style="display:inline-block; padding-left:7px;padding-top:10px;">
 <select class="styler width-400" name="subject" id="subject">
 <option value="-1">-------------------------Select the item------------------------</option>

 <option value="51">GWA: Russian language</option>
 <option value="53">GWA: Physics</option>
 <option value="55">GWA: computer science</option>
 <option value="56">GWA: Biology</option>
 <option value="57">GWA: History (twentieth century)</option>
 <option value="68">GWA: Literature</option>
 <option value="58">GUE of Geography</option>
 <option value="52">GWA: Mathematics</option>
 <option value="54">GWA: Chemistry</option>
 <option value="59">of GUA: English</option>
 <option value="60">GWA: German</option>
 <option value="61">GWA: French</option>
 <option value="62">United GWA: social Studies</option>
 <option value="63">United GVA: Spanish</option>
 <option value="2">OGE: Mathematics</option>
 <option value="7">OGE: History (twentieth century)</option>
 <option value="17">OGE: History (without the twentieth century)</option>
 <option value="6">OGE: Biology</option>
 <option value="3">OGE: Physics</option>
 <option value="8">OGE: Geography</option>
 <option value="9">OGE: English</option>
 <option value="10">OGE: German</option>
 <option value="11">OGE: French</option>
 <option value="13">OGE: Spanish</option>
 <option value="1">OGE: Russian language</option>
 <option value="5">OGE: computer science</option>
 <option value="12">OGE: social Studies</option>
 <option value="4">OGE: Chemistry</option>
 <option value="18">OGE: Literature</option>
</select>
</div>

 <div style="display:inline-block; padding-left:7px;padding-top:10px;">
 <select class="styler width-400" name="examdate" id="examdate">
 <option value="0">-------------------------date of exam------------------------</option>
</select>
</div>

 <div style="display:inline-block; padding-left:7px;padding-top:10px;width:400px;">
 <input type="text" class="styler" placeholder="Series document" value="" name="docS" id="docS" style="width:380px;">
</div>

 <div style="display:inline-block; padding-left:7px;padding-top:10px;width:400px;">
 <input type="text" class="styler" placeholder="document Number" value="" name="docN" id="docN" style="width:380px;">
</div>

 <div style="display:inline-block; padding-left:7px;padding-top:10px;width:800px;" align="center">
 <input type="button" value="get result" class="google_buttons add_news" onclick="get_result();" style="width:280px;">
</div>

 <div id="result">
&nbsp;
</div>

the <script>
 function get_result() {

 var SubjectCode = $("select#subject").val();

 var ExamDate = $("select#examdate").val();

 var DocN = $("input#docN").val();

 var DocS = $("input#docS").val();

 $.post("/ajax/get_oge_result.php", {
 SubjectCode: SubjectCode,
 ExamDate: ExamDate,
 DocN: DocN,
 DocS: DocS
 }, onAjaxSuccess);

 onAjaxSuccess function(data) {
$("div#result").html(data);
}
}

 $(function() {

 //Uploading pages to the selector
 $('#subject').on('change', function() {
 var SubjectCode = $('select#subject option:selected').val();

 $.post("http://sarrcoko.ru/ogeresult/ajax/get_date_by_exam.php", {
 SubjectCode: SubjectCode
 }, onAjaxSuccess);

 onAjaxSuccess function(data) {

$('#examdate').html(data);

 setTimeout(function() {
 $('input, select').trigger('refresh');
 }, 1)
}
});

});

 (function($) {
 $(function() {
$('select#subject').styler({
 selectSearch: false,
 selectSearchLimit: 2,
 onSelectOpened: function() { /*$("#dialog-edit").height(400);*/ },
 onSelectClosed: function() { /*$("#dialog-edit").height(175);*/ }
});
});
})(jQuery);
 (function($) {
 $(function() {
$('select#examdate').styler({
 selectSearch: false,
 selectSearchLimit: 2,
 onSelectOpened: function() { /*$("#dialog-edit").height(400);*/ },
 onSelectClosed: function() { /*$("#dialog-edit").height(175);*/ }
});
});
})(jQuery);
</script>

</section>

So that script with AJAX request worked on that site? How can I do that?
March 23rd 20 at 19:39
1 answer
March 23rd 20 at 19:41
To make a request to your server, which will request data on sarrcoko.
For CORS.
CORS, of course... not many did Not understand your logic: how will I query the data with sarrcoko, if for example with code:
//Uploading pages to the selector
 $('#subject').on('change', function() {
 var SubjectCode = $('select#subject option:selected').val();

 $.post("http://sarrcoko.ru/ajax/get_date_by_exam.php", {
 SubjectCode: SubjectCode
 }, onAjaxSuccess);

 onAjaxSuccess function(data) {

$('#examdate').html(data);

 setTimeout(function() {
 $('input, select').trigger('refresh');
 }, 1)
}
 });

Climbs error:
Access to XMLHttpRequest at 'http://sarrcoko.ru/ajax/get_date_by_exam.php' from origin 'MYSITE' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
- gilda.Zbonc commented on March 23rd 20 at 19:44
@gilda.Zbonc, On your server, write a script (PHP, Node.JS, Python or whatever you have).
Your AJAX request from the browser client accesses this script, the script receives data from sarrcoko and sends it to the client. - chris.Kozey79 commented on March 23rd 20 at 19:47
@chris.Kozey79can be an example, don't quite understand how to do it? - kavon_Rice commented on March 23rd 20 at 19:50
@chris.Kozey79how do I get the data from the source site, if we need to send a Post request, I mean you can do that with Ajax, but in any case, as I said, it gives an error CORS, so about my pseudo script on my server, not the channel. What options are there? - kavon_Rice commented on March 23rd 20 at 19:53
@kavon_Rice, your website is the backend there? If not, you will not get.
If there is, it means the backend, such as cURL in PHP. - chris.Kozey79 commented on March 23rd 20 at 19:56
@chris.Kozey79, I wrote that file access on the website sarrcoko no. There are only links to PHP scripts that are accessed by Ajax Post method. - kavon_Rice commented on March 23rd 20 at 19:59
@kavon_Rice, what have access to the files on the website sarrcoko? Your website backend is, or is it a purely static website? - chris.Kozey79 commented on March 23rd 20 at 20:02
@chris.Kozey79you about it... Well, there - kavon_Rice commented on March 23rd 20 at 20:05
@chris.Kozey79, how do I implement it using cURL, it is necessary to first send an Ajax request to my script, and my script will send the request to a script on another site and then returns the result - kavon_Rice commented on March 23rd 20 at 20:08
@kavon_Rice, Exactly. - chris.Kozey79 commented on March 23rd 20 at 20:11
@chris.Kozey79, well, that's the question - how do I post a request to send korlam? - kavon_Rice commented on March 23rd 20 at 20:14
@kavon_Rice,
www.lmgtfy.com/?q=%D0%BA%D0%B0%D0%BA+%D0%BE%D1%82%... - chris.Kozey79 commented on March 23rd 20 at 20:17
@chris.Kozey79, I found the following example:
<?php
 if( $curl = curl_init() ) {
 curl_setopt($curl, CURLOPT_URL, 'http://mysite.ru/receiver.php');
 curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
 curl_setopt($curl, CURLOPT_POST, true);
 curl_setopt($curl, CURLOPT_POSTFIELDS, "a=4&b=7");
 $out = curl_exec($curl);
 echo $out;
curl_close($curl);
}
?>


Where CURLOPT_POSTFIELDS, what to me there to transfer?

Here is the query that I make to the script above:
$('#subject').on('change', function() {
 var SubjectCode = $('select#subject option:selected').val();

 $.post("http://sarrcoko.ru/ajax/get_date_by_exam.php", {
 SubjectCode: SubjectCode
 }, onAjaxSuccess);

 onAjaxSuccess function(data) {

$('#examdate').html(data);

 setTimeout(function() {
 $('input, select').trigger('refresh');
 }, 1)
}
 });
- kavon_Rice commented on March 23rd 20 at 20:20
@kavon_Rice,
curl_setopt($curl, CURLOPT_POSTFIELDS, ['SubjectCode' => SubjectCode]);
- chris.Kozey79 commented on March 23rd 20 at 20:23
@chris.Kozey79, Here is what my script output - a1c98f2edf.png
But nothing happened when I chose the subject, but should ideally receive the exam dates.
548b4c94e3.png - gilda.Zbonc commented on March 23rd 20 at 20:26

Find more questions by tags iframeHTMLPHP