I have used javascript (and jquery) to use google api for its search engine. But now I think it must be done on server side.Using it on client side can expose some critical portion of site to client and make it vulnerable. Is there anyway I can port that javascript code as it is on server side.
I am using php as server side script.
You probably want to port whatever code you are using to PHP, or rewrite it. There is no easy way to execute JavaScript in PHP, but most often, rewriting the code is fairly easy.
JavaScript can be used on server side, but this requires massively reconfiguring the server, and getting into a completely new technology. It is most likely not what you want.