0

I've been working on a dynamic webpage that uses quite a bit of jQuery. I'm going to give my users the ability to post short messages similar to Facebook or Twitter and I want to use PHP/mySql to do so. So while most of the page will be written in Javascript/jQuery, I will have a div positioned on the side displaying a Facebook like status feed.

My question is this...Is it ok to readily mix PHP and jQuery/Javascript or will this lead to problems?

I'm fairly new to programming so I thought I would ask

Parag Tyagi
  • 8,780
  • 3
  • 42
  • 47
jonjon
  • 121
  • 2
  • 10

2 Answers2

2

Yes, that is perfectly fine, and in some situations a perfect solution, combined the powers of both.

Good to remember: Never trust the input of javascript (clientside data), it can always have been altered to mess up your website. BUt the same for for plain'ol'inputs.

To give you an example right here in SO, when someone votes, you will see the 1-up aswell-> ajax.

Martijn
  • 15,791
  • 4
  • 36
  • 68
  • As being as the OP is looking to use mysql, you should have referenced [this link](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) about SQL Injections – Jack Apr 12 '14 at 18:00
0

Its not a problem at all. Look into AJAX, as its designed to do exactly what you're trying to do: communicate from Client to Server in the background. This way you don't have to load a page just to send/receive data to/from the server.

Outsider
  • 550
  • 3
  • 9