b
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
No. Javascript is read by the client (like HTML) and parsed at the client's end.
If you have Javascript disabled it won't work, doesn't matter how you send it to the client.
Server-side languages such as PHP are parsed on the server and then the output is sent to the client.
Edit: I beat feyd, wooooooooooo.
If you have Javascript disabled it won't work, doesn't matter how you send it to the client.
Server-side languages such as PHP are parsed on the server and then the output is sent to the client.
Edit: I beat feyd, wooooooooooo.
Last edited by jayshields on Sat May 20, 2006 9:25 am, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
All that this javascript does is submits a form. I'm struggling to see a purpose in doing that server-side, unless you're trying to complete forms on other sites from your PHP scripts?boujin wrote:So what code could I use to substitute this javascript?
In which case you need cURL to send POST data to the other server. Perhaps some reading up on the HTTP protocol and the 2-tier architecture would be a help:
http://en.wikipedia.org/wiki/Client/ser ... chitecture
http://en.wikipedia.org/wiki/Http#Request_methods
http://en.wikipedia.org/wiki/Http#Sample
You basically are trying to send a HTTP POST request to a server.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I think we need to think about what we're trying to acheive a little better hereboujin wrote:I have a 100% javascript shopping cart on my web. I have had many clients complain because they had problems with it (they weren't able to "checkout" and buy on my site). I acknowledge that a percentage of them could be scams but I am sure that this was the case with many of them. My best guess is because it is made with javascript (probably because some clients have part/all of javascript disabled on their browser).
So I bought a cart made in 100% PHP (server side) but it has this only javascript code in it. So here I am trying to find a way to substitute this only javascript with some other server side language. I must say that I have basically no idea of javascript nor php (I see both very complicated) but I do have quite a good knowledge of xhtml (very easy to understand).
Apparently the javascript does this:
"calTax is a simple little function that gets called when the user selects a state; that function then re-submits the whole form back to hello.php with the state info so it can determine the tax status..."
Is there any way to make this function server side or maybe you need more information?
So far we know, the js we have here submits the form (client-side)
It executes when the user changes the state (client-side, 100% non-avoidable)
It sends data back to hello.php (presumably to recalculate tax?)
So the problem here: There's a level of user input involved which of course happens on the clinet's computer.
If you want to remove the javascript go ahead, you'll just need to place a little "Update" button (which is just another <input type="submit">) right next to the part in the form where the user changes the state.
Personally I'd keep the javascript and just add the update button (maybe even in a <noscript> tag) to the form. This way if the user has JavaScript they will get an enhanced experience with the form, otherwise they'll just have an extra click to make.
To summarise, you can't have the server respond to user input without something happen on the client-side.
Good luck