Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
How Can I set and send GET data when characters of an URI exceed 5,000

I am using a Laravel blade.

My code below happens error when the size of item of textarea is huge. I am looking for a way to solve it.

Everyone. How should I send a huge text to server? How should I modify my codes?

Blade(JavaScript)

    function sendByGet()
    {
        var items =  document.getElementById("item").value;
        var param = "?items="+items+"&id={{$id}}";
        var url = {{(url)}} + encodeURI(param);

        let result = fetch(url);
        result.then(response => response.json()).then(
                responceObject =>{
                    
                    }
                } 
    }

Controller PHP

 public function receivebyGet(Request $request)
    {
        $lineArray  = array();
        $slipData = explode("\n", $request->items); 

Error

the date is replaces <huge_text> (Actual data is text(5000 characters))

phpbladeName?id=01:270 GET https://test.com/test/send_by_get?&item=<huge_text> 414 sendByGet @ confirmation?id=01:270 onclick @ confirmation?id=0:244 VM142:1 Uncaught (in promise) SyntaxError: Unexpected end of JSON input at phpbladeName?id=01

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Move your data to the BODY

function sendByGet(url) {
    const items =  document.getElementById("item").value;
    const param = encodeURI("?id={{$id}}");

    fetch(url + param, {
        method: 'GET',
        headers: { 'Content-Type': 'plain/text' },
        body: items,
    })
        .then(response => response.json())
        .then( ... );
}

PHP Controller (assuming being Laravel)

public function receivebyGet(Request $request) {
    $lineArray = array();
    $slipData = explode("\n", $request->getContent());
    ...
}

Query size limit

As mentioned by Peter Krebs the maximum URL size (which includes the Query) is 2000 characters. So you cannot expect your system to reliably work if url is longher than 2000. Read more here.

GET body

As pointed out by Jabaa you should semantically choose the method, not technically. But this is something that has evolved over time (initially the GET body was supposed to be rejected/ignored) read more here. Hence you should consider it carefully and verify that all the parties involved (server, browser, proxies, cache) supports it properly. This is why oftentimes developers choose to violate semantics and use a POST method.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda