Solved

jQuery and Ajax, writing results to a div on a parent page

Posted on 2012-03-13
2
375 Views
Last Modified: 2012-03-13
I have a web page with several links on it.  When a link is clicked it pops up a jQuery modal box, with a form loaded from another page using ajax:

function getInfo(prodID){
            
$.ajax({
type: "POST",
url: "getProduct.asp",
data: "prodID=" + prodID,
timeout: 6000,
success: function(data, textStatus){
if (data!="ERROR")
{
     $( "#dialog-form" ).html(data);
    $( "#dialog-form" ).dialog( "open" );
}
  else
{
                                          
}
}
});
return(false);
}

getprod.asp is a form that loads with specific fields.  when the user clicks submit on the getprod.asp form, i want to process another ajax page (addtocart.asp) - and then update a div (#cartInfo) on the original page with updated cart information.

I'm not sure how to communicate from the getprod.asp's Ajax results to the parent page that launched the modal dialog box.    $( "#dialog-form" ).html(data); is what I use to update the modal dialog box  - and I imagine it would be something like - $this.$parent("#cartInfo").html(data); - but I don't know.  

Any ideas?  I don't know if I need to post more information.

Thanks for your help!
0
Comment
Question by:slightlyoff
2 Comments
 
LVL 9

Accepted Solution

by:
wellhole earned 500 total points
ID: 37714932
A modal dialog box is still part of the page. $("#cartInfo") will grant you access to that element on your page even if you call it from the modal box.
0
 
LVL 1

Author Closing Comment

by:slightlyoff
ID: 37715075
you frickin' ROCK!  Thanks :)  

That was much easier than I was thinking it would be.

I really appreciate your quick response!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can't get js code to execute 8 33
Use Mid in Html 6 23
Two decimal 5 30
Table style position to the left 8 26
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question