gergy008 Posted February 3, 2011 Share Posted February 3, 2011 When ever I try to google this I always get it the other way round "Calling PHP from jQuery" which is now what I need. Basically I want, When the script starts, For PHP to check if an array is empty and if it's not call a jQuery function (This would be the jQuery UI Dialog box). If you can help me here or even post a link to a resource then I will kiss ya. No homo. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Maq Posted February 3, 2011 Share Posted February 3, 2011 This is done all the time. What's the issue? Quote Link to comment Share on other sites More sharing options...
gergy008 Posted February 3, 2011 Author Share Posted February 3, 2011 This is done all the time. What's the issue? The issue here is I don't know how to make it work how I described, How to open a jQuery UI Dialog through PHP. Sounds easy but I'm still learning like. Thanks. Quote Link to comment Share on other sites More sharing options...
Maq Posted February 3, 2011 Share Posted February 3, 2011 You have to put the call in script tags: <br /> $("#dialog").dialog();<br /> Quote Link to comment Share on other sites More sharing options...
gergy008 Posted February 16, 2011 Author Share Posted February 16, 2011 So I just echo that and it works? Sweet, Rather simple [/latepost] Quote Link to comment Share on other sites More sharing options...
petroz Posted February 16, 2011 Share Posted February 16, 2011 I work in a PHP MVC environment and I do a ton of javascript. The easiest path I've found is having a <body onload="$onload"> on my view files. Basically, when I a specific script is run, if there is a defined onload javascript in my php file, the view file will render the onload tag to the body. My view works like so. <body <?php if(!empty($onLoad)) { echo 'onLoad="'.$onLoad.'"'; }?>> Then the controller would look like this. function add() { if($_SERVER['REQUEST_METHOD'] == "POST") { redirect('record/add'); } else { //set onLoad $data['onLoad'] = 'PO.add();'; // this is the javascript method I want to fire when the doc is ready //load the view $data['main_content'] = "record/add"; $this->load->view('includes/template', $data); } } Might be overkill for what you are looking to accomplish... but its a different approach. Quote Link to comment Share on other sites More sharing options...
Maq Posted February 17, 2011 Share Posted February 17, 2011 So I just echo that and it works? Sweet, Rather simple [/latepost] Yep, try it out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.