aubake01 Posted August 2, 2012 Share Posted August 2, 2012 Ok, this is my first post and it's kind of long, so bear with me... I have these php pages. One is the user info page which loads tables of the user's info. The table data is generated by functions located in another file. The user has the option of editing their info which brings up a popup window that contains the editing page. Once the editing is done, the window closes. I would like the user info page to then automatically refresh the table that has just been edited. Currently I have a test button on the user info page that calls a jquery script and refreshes the appropriate table. This works fine, but it is manual, and I would like it to be done automatically. I tired including the user info page on the editing popup page and then calling the script when the user clicks the save button, but it says the function is undefined. If I put the script code on the popup page, then the tables and divs are undefined. So I need help getting this to work. I'm not sure how to do this. I'm pretty new to all of this. I think maybe an ajax call from the popup page telling the user info page to update the table would work, but I'm not sure how to do that. Any ideas or thoughts on how to fix this problem supported with sample code would be extremely helpful!!! Let me know if this is confusing or if I need to add more details. Thanks in advance!!! Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 2, 2012 Share Posted August 2, 2012 You're having a problem with scope. Yes, you'll need to use AJAX. There are tons of tutorials on this throughout the web. When you get stuck, let us know. Essentially, You're going to need to send your edits through ajax to a script that will modify the user's information. The "save" button on the popup is merely to initiate the ajax request with the updated fields. You need to set up a response in the receiving script to tell the pop-up JS the edits were successful. Upon this response, the window can close. However, i do not believe that you'll be able to fire a new request from another pop-up window. However, using modal boxes you will not lose scope. Quote Link to comment Share on other sites More sharing options...
aubake01 Posted August 3, 2012 Author Share Posted August 3, 2012 Is there a way to do that with jquery? I have head that jquery makes ajax calls much more simple which would be great for someone like me. What I would like is when the 'edit' button is clicked on the main page, it sends a request to the popup window, opens the popup window, and waits for a response. Then the popup window gets the call and waits for the user to finish editing their content. When they click 'save', the request is sent back to the main page and the window closes. The main page receives the request and knows to reload the table data. Would that be possible with jquery? Could someone point me in the right direction? I have looked at a couple ajax tutorials as well as jquery tutorials, all basic and none sending calls to different pages so I am not sure how to start. Thanks again!!! Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 3, 2012 Share Posted August 3, 2012 Once you go pop-up you've lost your scope, as it's a new page and a new instance of the javascript. Use a modal box instead. Yes, jQuery is very efficient and user-friendly with this. http://api.jquery.com/ajaxComplete/ http://api.jquery.com/jQuery.post/ there's another link i can't seem to find atm Quote Link to comment Share on other sites More sharing options...
aubake01 Posted August 6, 2012 Author Share Posted August 6, 2012 Is it possible to use a modal box without physically having the files on your server like with jquery? Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 6, 2012 Share Posted August 6, 2012 the user editing page is from a different server??? Quote Link to comment Share on other sites More sharing options...
aubake01 Posted August 6, 2012 Author Share Posted August 6, 2012 No, I was talking about the actual files needed to use modal box, like the prototype.js, scriptaculous.js, and modalbox.js. Can you use modal box without physically having these files on your server, such as including a web library like you can do with jquery with the 'src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"' code? Is that possible do you know? Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 6, 2012 Share Posted August 6, 2012 you want the modal boxes to come from another server? why? modals are typically hidden (or loaded via ajax for a cleaner DOM) until called. see: http://jqueryui.com/demos/dialog/#modal-form Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 6, 2012 Share Posted August 6, 2012 No, he wants the JS files hosted somewhere else. Why, I don't know. But he wants the .js on a public server like google API does with jquery. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 7, 2012 Share Posted August 7, 2012 All files referenced in the HTML header can be stored on external servers, though it is normally not recommended. Not only will it increase the page response time quite significantly, but you're also at the mercy of these third party servers being up and running at all times. Not to mention the fact that the files themselves could be changed at any time, rendering your page inoperative without any action from you or your visitors. So, yes: It is possible, but it is highly recommended to store the files locally. Quote Link to comment Share on other sites More sharing options...
aubake01 Posted August 7, 2012 Author Share Posted August 7, 2012 OK, thanks! I was just asking because the server I am using isn't my own personal machine, and I didn't have permissions to upload new files, just edit pre-existing ones. So I talked to the guy and he put the files on there for me so I am good to go. Now I just need to get it to work... Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 7, 2012 Share Posted August 7, 2012 You're welcome, glad we could help. Quote Link to comment Share on other sites More sharing options...
aubake01 Posted August 7, 2012 Author Share Posted August 7, 2012 Hey thanks Mahngiel for that last example. That is pretty much what I need. But is it possible to load another php that contains a form instead of a form on the same page via a div tag? If so, how would you do that and also pass it some variables, for instance $userid, $session, etc.? Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 7, 2012 Share Posted August 7, 2012 use $.load() to bring up a new html page and post the data from it via ajax to a .php script Quote Link to comment Share on other sites More sharing options...
aubake01 Posted August 8, 2012 Author Share Posted August 8, 2012 Could you give me an example of what you mean? Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 8, 2012 Share Posted August 8, 2012 Google "jQuery php ajax tutorial" and you'll find LOTS of examples. 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.