I am sending a GET
request via $.getJSON
, and the data sent is really big. I need to get a result after the processing of my data, so POST
ing it instead doesn't seem to be a solution. Any idea? The data sent is a string encoded as a json. I thought about sending it without encoding it first, as an array, but then my response will be only "Array", so there is no way of decoding it afterwards.
Asked
Active
Viewed 4,964 times
0

Cornelia Secelean
- 403
- 1
- 4
- 14
-
`base64` or similar encode it, then decode it again server side? – naththedeveloper May 23 '13 at 16:38
-
1Seems a bit odd to send json in a get request. Why wasn't posting it a solution? Can we know anything more about the structure of what you're trying to send? Thanks. – Tom May 23 '13 at 16:38
-
2@FDL — `base64` will make the data **bigger**. It is designed to allow binary data to be encoded as text, it isn't a compression algorithm. – Quentin May 23 '13 at 16:39
-
@Tom I am getting for example one facebook user's notes. A note might be as long as a novel. And I need to post that data. I don't know if I can find any encoding that would transform it into something short enough. – Cornelia Secelean May 23 '13 at 16:42
-
Then have you tried posting it and using chunked transfer encoding? Also,yes Base64 encoding whilst sometimes a really good idea wouldn't help you with a size issue. – Tom May 23 '13 at 16:43
-
voila: http://stackoverflow.com/questions/10753725/jquery-support-transfer-encodingchunked-how – Tom May 23 '13 at 16:44
-
@Tom messes up with my brain. Thanks, I'll try it. I'm quite new to all webdevelopment so It's still hard for me to understand some things – Cornelia Secelean May 23 '13 at 16:49
-
Oh well, good luck! Looks like what you're doing is cool. All very good suggestions here other than mine. The idea with chunked is that what you're trying to send is really too big to send in one go. So your client and server send up "chunks", which are each annotated using some special characters to tell the server or client what to expect next. On the way down, the browser should do this for you. – Tom May 23 '13 at 16:52
2 Answers
1
use $.ajax
this way:
$.ajax({
dataType: "json",
type:'POST',
url: url,
data: data,
success: function(response){...}
});
afterall $.getJSON
its just a wrapper of $.ajax

Jarry
- 1,891
- 3
- 15
- 27
-
how can I store the response? The response might be something as large as the request – Cornelia Secelean May 23 '13 at 16:45
-
You won't have to worry about it, AFAIK. The browser handle it - just use php to write it however you need it. – Tom May 23 '13 at 16:49
-
@Tom How can I get the response? That's what I still don't understand. With getJson i had `$.getJSON("myphp.php",{data:"data"},function(response){//handle response});`. How can I do it here? – Cornelia Secelean May 23 '13 at 16:56
-
2
-
3
0
If you need to send so much data that it exceeds the limit on URL length, then you either have to find some way to express that data in fewer characters or you have to use POST. So you have to use XHR.
I need to get a result after the processing of my data, so POSTing it instead doesn't seem to be a solution.
Using POST should not be a barrier that that.
If you are depending on JSON-P for a cross-domain request then you will have to use some alternative means to bypass the same origin policy such as a CORS of a proxy.