There is a html page from which you need to send a very long string of PHP characters to a handler on another domain via $ .ajax. The string will constantly increase over time and at some point may already have tens or even hundreds of thousands of characters. I tested and found out that the length of the URL in the Ajax request can be about 4800 characters , more than Ajax does not miss, at least in Chrome. The first thing that comes to mind is to break the entire line into parts no larger than 4800 and send all the parts alternately, at some interval, and then in the handler to collect everything back into a single whole. Other solutions are welcome.
My request for Ajax:
$('button').click(function() { var veryLongString = 'Very long stringggggggggggg'; $.ajax({ method: 'GET', url: 'http://mydomain.com/myhandler.php', dataType: 'jsonp', crossDomain: true, jsonpCallback: 'myCallback', data: {key: veryLongString}, success: function(data) { console.log(data); } }); }); To break apart as elements of an array found (again, other ideas are welcome):
veryLongString.match(/.{1,4800}/g); And what to do next - I do not know. Like through setInterval () or how?
ps. How to collect on the side of the handler while the question does not bother, while only how to send in parts (who knows who knows, maybe you need to immediately take the handler into account ...)
When switching to method: 'POST'
I try to send about 12,000 characters, but still I get the same error in the console (with the word GET for some reason) and the request is not sent. Mistake:
GET http://mydomain.com/myhandler.php?callback=jQuery111103417691031936556_1…20%25D0%25BE%25D1%2581%25D0%25B5%25D0%25BB%25D1%258F%2522)&_=1445978068736 send @ jquery-latest.min.js:4 m.extend.ajax @ jquery-latest.min.js:4 (anonymous function) @ mypage.html:2014 m.event.dispatch @ jquery-latest.min.js:3 r.handle @ jquery-latest.min.js:3 Line 2014 is $.ajax({
No 'Access-Control-Allow-Origin' header is present...AndcrossDomain: true,also not helps - stckvrw