469,329 Members | 1,373 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,329 developers. It's quick & easy.

Using AJAX to refresh part of page

22
Hi, I'm looking for a way to refresh just one part of a page (a div layer) rather than the entire thing. It has been suggested to me that i use AJAX to do this - however I have no knowledge whatsoever of this. Could someone confirm that this could be done and point me in the right direction?

Thanks....
Nov 14 '06 #1
7 47682
ronverdonk
4,258 Expert 4TB
Yes, you can do that using Ajax. It can be triggered using a Javascript event.

See thread http://www.thescripts.com/forum/thread561233.html for a complete discussion about and a solution for dynamically populating drop-down lists using Ajax.

Especially post number http://www.thescripts.com/forum/post2198507-5.html shows some sort of process overview of this solution.

Once you have read that, you'll better understand the possibilities for your situation.

Ronald :cool:
Nov 14 '06 #2
Luongo
22
Thanks ronverdonk.

Along these same lines, though more specific, is it possible to submit a form and have just that layer refreshed? I saw in your discussions the use of a select box that would display info onChange. However, in one case, I'd like to be able to actually pass values (hidden values and the coords_x/coords_y values on an image input type) without refreshing the entire page as mentioned. Can this be done using the methods you described in earlier posts? Thanks...
Nov 14 '06 #3
ronverdonk
4,258 Expert 4TB
When passing values in a regular form, you can simply create a button or image element that will automatically pass all values of a form to the script designed by the action attrib of the form tag.

In general, such a solution bundles up all values and then passes them on to said script with little or no interaction necessary on the part of the developer.

Submitting a form via Ajax en then passing the values to a script is a touch more complicated.

So in short: yes you can submit a form using Ajax, but it comes at the cost of - not to be underestimated - additional complication.
Question is: is the result worth the effort?

As to the last question: you can pass any value from a DOM reachable field to the server using Ajax, but to start the process you'll need some sort of trigger (such as a Javascript event).

Ronald :cool:
Nov 14 '06 #4
ronverdonk
4,258 Expert 4TB
Continuing my revious post:

For Ajax form submissions there is an Ajax toolbox available, that may (or may not, I haven't looked closely into it) assist you in your decision to use form submission via Ajax. See link Ajax Toolbox section 'Sample', 'form submission'.

Ronald :cool:
Nov 14 '06 #5
Luongo
22
Thanks again Ronald. I have managed to get a test form up and running using these methods. However, one problem I cannot solve is how to pass the coords_x and coords_y values of an image input type through ajax. Usually an image submit button would submit the form and also generate those coordinate values. However, with Ajax it just seems to submit the form. I will continue searching, but if you know of a way around this please let me know.
Nov 15 '06 #6
ronverdonk
4,258 Expert 4TB
Is it not possible to issue an GetImageSize($image) command on that image and store the values for H and W in the form somehow?

Ronald :cool:
Nov 15 '06 #7
Luongo
22
Yes, but what I need is the exact coordinates where the image is clicked, which is what the coords_x and coords_y values of the input provide. Do you know of a different way I could get these coordinates and store them as hidden values, rather than having to wait until the form is submitted?
Nov 15 '06 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Jim | last post: by
10 posts views Thread by Piotr Nowak | last post: by
25 posts views Thread by Piotr Nowak | last post: by
6 posts views Thread by John Doe | last post: by
5 posts views Thread by Kaante | last post: by
5 posts views Thread by SAM | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.