Welcome Guest, Not a member yet? Register   Sign In
Update database without reloading view? (Involving Google Maps API)
#2

You can't call PHP code from JavaScript. You can generate JavaScript code with PHP, like you do in the code above. But you can't call $this->CI =& getInstance() or any other PHP function when the user click a button. JavaScript is executed in the browser on the user's computer. PHP is executed on the web server.

But you can achieve this by making an ajax request. The JS code call the web server with whatever it needs to do (example: http://website.com/some-controller/some-function/id), the PHP code make an update in MySQL and return success or error code, the JS code catch the code and call a function to update the web page dynamically.

There's a ton of tutorial to do this with jQuery or plain JavaScript. Let us know if you can get it to work!
Reply


Messages In This Thread
RE: Update database without reloading view? (Involving Google Maps API) - by includebeer - 01-20-2020, 04:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB