Solved

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

Posted on 2012-03-13
2
366 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now