How can I pass a long javascript string to PHP hook_menu in Drupal? On mysite/build-order I have a long order code that I'm assembling using Javacsript and sending via _GET in the URL to a hook_menu page for processing.

It can be as long as this (or longer), and am sending it to the create-order page like this:

&lt;script type="text/javascript"&gt;
    //...building code
    var orderCode = "sku:OR-4x4&gt;qty:2&gt;prc:55.00&gt;nfo:OR-4x4,sku:CVR&gt;qty:1&gt;prc:50&gt;nfo:OR-4x4,sku:PF&gt;qty:15&gt;prc:2&gt;nfo:OR-4x4 (sdfsdfg),sku:EM&gt;qty:2&gt;prc:12.95&gt;nfo:OR-4x4 (sdfsdfg),sku:SC&gt;prc:25&gt;qty:4&gt;nfo:Some description,sku:DB&gt;qty:10&gt;prc:4&gt;nfo:Some description,sku:ES&gt;qty:10&gt;prc:3&gt;nfo:BlahBlah,sku:OR-4x4&gt;qty:2&gt;prc:55.00&gt;nfo:OR-4x4,sku:CVR&gt;qty:1&gt;prc:50&gt;nfo:OR-4x4,sku:PF&gt;qty:15&gt;prc:2&gt;nfo:OR-4x4 (sdfsdfg),sku:EM&gt;qty:2&gt;prc:12.95&gt;nfo:OR-4x4 (sdfsdfg),sku:SC&gt;prc:25&gt;qty:4&gt;nfo:Some description,sku:DB&gt;qty:10&gt;prc:4&gt;nfo:BlahBlah-visiondelimiter-Phasellus laoreet lorem vel dolor tempus vehicula. Curabitur blandit tempus ardua ridiculus sed magna. Quisque placerat facilisis egestas cillum dolore.-visiondelimiter-eventName";

    var url = '/create-order/' + orderCode;
    window.location.replace(url);
&lt;/script&gt;


Ive implemented a hook_menu setup in my custom module called "create_order_menu" and it works fine.

function mymodule_create_order_menu($ordercode){

    // do stuff with $ordercode

}


It all works fine. The only problem is that the order code string passed through the URL can sometimes be twice as long and it trips a 404 Error in the mysite/create-order page. When I shorten the code, it works. When I lengthen it again, it breaks.

Is there a better way to send such a lengthy variable to my hook_menu page setup?
I would suggest that you consider some pretty substantial changes to how you're doing things.

I would recommend using an AJAX request, probably with POST rather than GET,  and don't try to do the redirect.   Just update the interface with a "success" message for the user.