Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send data from outside site to my server via AJAX?
    primarykey
    data
    text
    <p>I am written the bookmarklet, which takes pictures and videos from a site and must send it to my server via AJAX. The problem is in crossdomain AJAX request - I have got an error:</p> <blockquote> <p>XMLHttpRequest cannot load <a href="http://mysite.com/community/bookmarklet/" rel="nofollow">http://mysite.com/community/bookmarklet/</a>. Origin <a href="http://www.some-nice-site.com" rel="nofollow">http://www.some-nice-site.com</a> is not allowed by Access-Control-Allow-Origin.</p> </blockquote> <p><strong>How to solve data sending to my server from third-part sites?</strong></p> <p>Note: I use only plane javascript, this is the stipulation of development.</p> <p>my code:</p> <pre><code>function getXmlHttp(){ var xmlhttp; if (typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } else { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } }; return xmlhttp; }; function vote(data) { var req = getXmlHttp(); req.onready = function() { if (req.readyState == 4 &amp; req.status == 200) { alert('OK'); } } req.open('GET', 'http://mydomain.com/community/bookmarklet/'); req.send(JSON.stringify(data())); }; function dataProcessing(){ //some processing return data; }; // I tried it, but not deeply understand. function JSONPresponse(){ document.getElementById('popup_body').innerHTML = 'done!'; }; (function(){ function pasteIt(){ // this function is builds the form, which get data for dispatch to my server. }; pasteIt(); document.getElementById('my_button').addEventListener('click', function() {vote(dataProcessing)}, false); }()); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload