mahmoud nezar sarhan
mahmoud nezar sarhan

Reputation: 756

sending query strings using Javascript

suppose that I have two pages ( A and B ) , and I want to pass insensitive data from A to B , why I shouldn't set a query string variables containing my data in the target page URL(B) , and then retrieve my data from there using javascript (window.location.href) too , I mean why I should use PHP $_GET array ?

Upvotes: 1

Views: 68

Answers (1)

Sudhansu Choudhary
Sudhansu Choudhary

Reputation: 3360

Putting my comments as the answer as suggested by OP,

php is server side, javascript is on client side.. Thumb rule- be it sensitive or insensitive data, use server side implementation for retrieving and changing..!

You can definitely use js.. it's more about perception, style and taste of your programming/coding(keeping this question in context). You can pass data using js(URLs as you have mentioned) or use server side implementation, it's up to you. However why server side should be preferred is because of security reasons, javascript can be modified at run time. But as you have stated the data is insensitive, you can absolutely go ahead with using js, if you feel comfortable with it.

And as @MonkeyZeus has commented, you could end up with ugly, long URLs. Especially if you have space(s) within a String that you are trying to pass as the data. It could look messy with (%20)s and stuff being added in the URL.

Upvotes: 2

Related Questions