Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery .get() only passing first two data parameters in url

I have a $.get() call to a PHP page that takes 4 GET parameters. For some reason, despite giving the $.get() call all 4, it only passes the first two. When I look at the dev console in chrome, it shows the URL that gets called, and it only passes action and dbname. Heres the code:

$.get('util/util.php', { action: 'start', dbname: db, url: starturl, crawldepth: depth }, function(data) {
        if (data == 'true') {
            status = 1;
            $('#0').append(starturl + "<ul></ul>");
            $('#gobutton').hide();
            $('#loading').show("slow");
            while(status == 1) {
                setTimeout("update()",10000);

            }
        } else {
            show_error("Form data incomplete!");
        }
    });

and heres the URL that I see in the developer console:

http://localhost/pci/util/util.php?action=start&dbname=1hkxorr9ve1kuap2.db

** EDIT ** I have been informed that I need to encode the URL that I am trying to pass through the header. How would I go about encoding it in javascript, and decoding it in php?

like image 700
The.Anti.9 Avatar asked May 02 '10 09:05

The.Anti.9


1 Answers

Are you sure that the starturl and depth variables are defined? A simple alert() before the $.get() will be enough to check.

In regards to your edit, you can encode strings in JavaScript with the encodeURIComponent function. And decode it back again in the PHP with urldecode. They both take one string argument.

like image 152
GlenCrawford Avatar answered Sep 22 '22 23:09

GlenCrawford