0

I am trying to pass long string variable to another page (fillDB.php) using window.location

window.location = "fillDB.php?encoding_str=" + JSON_encoding_str;

but the string does not passed completely to fillDB.php, here is the code in fillDB.php:

$encoding_str = json_decode($_REQUEST['encoding_str']);
echo $encoding_str;

the string is printed but it is not complete, I do not know where is the problem!

I've assigned value to encoding string:

encoding_str += isSimilar_DB(game)+","+reaction[3]+";";

then used JSON.stringify:

var JSON_encoding_str = JSON.stringify(encoding_str);

to make thing clear:

isSimilar_DB(game) 

is a function that returns a long string and

reaction[3]

returns an ID

when passing the whole string JSON_encoding_str, reaction[3] is printed correctely but the returned string(isSimilar_DB(game)) is not complete

EDIT: I've solved the problem. I thought that the problem is the length of the string or the limit length of the URL, but I found that the problem was that the string returned from isSimilar(game) function contained the less than letter "<", so the string is printed until it reach to "<" and stop, I still do not know the reason but any way I replaced "<" with "=" and it worked fine. Thank you all.

  • show the part where you assign value to JSON_encoding_str – Ramon Marques Jun 15 '17 at 21:00
  • I've assigned value to encoding string: encoding_str += isSimilar_DB(game)+","+reaction[3]+";"; then used JSON.stringify: var JSON_encoding_str = JSON.stringify(encoding_str); – Norhan Foda Jun 15 '17 at 21:03

1 Answers1

0

There is a character limit for URL. It's different for different browsers. Overall, you should not have urls with more than 2000 characters. You can check this thread: What is the maximum length of a URL in different browsers? If you are over this limit, your url will be cut.

Marina Melin
  • 162
  • 5
  • 10