Forum

HomeHomeCoreCoreGeneralGeneralCallbacks when AJAX call is completeCallbacks when AJAX call is complete
Previous
 
Next
New Post
2/22/2010 8:23 PM
 

I just recently tried to trigger two ows.Fetch() calls in a row (fetching data to two different DIV's on the page.) In practice, it appears that, while both calls get sent to the server, only the second displays on the screen.

Is there any way of queueing multiple AJAX calls without having to include a (spaghetti code) script block in the first response that calls the second? I was hoping to either have OWS queue each request and automatically fire the next queued request when the one before it completed, or to have a hook to register a JavaScript function called to be called when a call is complete.

If this doesn't exist, a simple AJAX call queue would be a nice addition.

New Post
2/23/2010 8:09 AM
 

I was trying to accomplish the same thing to populate a jQuery Accordion structure. Kevin Schreiner came up with a workable solution that uses the jQuery replace method to mimic what you're attempting:

http://www.openwebstudio.com/Communit...

If you look at the Advanced portion of the explanation, you'll see where the jQuery replace method is employed. A single ows.fetch call can accomplish multiple actions using this method. Here's how I've made it work:

  • Load the page with a No Query Template that includes all of the Divs/HTML that you want to alter with subsequent calls. Example:

<h3><a href="#">Customers - <span id="CustTitle"></span></a></h3>
<div id="divCust" name="divCust">
Original Customer Content
</div>
<h3><a href="#">Sites - <span id="SiteTitle"></span></a></h3>
<div id="divSite" class="demo">
Original Site Content
</div>

<div style="display:none;" id="divResult"></div>

  • Your ows.fetch call needs to target the <div id="divResult"></div>
  • After the ows.fetch is called, perform the queries to get the data that you need to create the new content for the Divs
  • Add another No Query Template containing the replacement content:

<div id="divCust_New">
New Customer Content
</div>
<div id="divSite_New">
New Site Content
</div>
<span id="CustTitle_New">
[@aSelectCust,Action]
</span>
<script type="text/javascript">
$('#divCust').html($('#divCust_New').html());
$('#divSite').html($('#divSite_New').html());
$('#CustTitle').html($('#CustTitle_New').html());
$('#divResult').html('');
</script>

The jQuery script at the bottom takes the content from the "_New" Divs and replaces the content in the orginal Divs. The final line clears the divResult. You can address as many Divs as you would like per ows.fetch call using this technique. It offers a great deal of flexibility when you need to modify multiple elements in a single OWS module.

I have attached an image that shows a sample config. Hope it helps!

New Post
2/23/2010 8:23 AM
 

I will take a look at the jQuery solution. As luck would have it, though, I had JUST finished a JavaScript "plugin" for OWS when I got your message. This just adds queueing capability to the already-existing ows.Fetch() functionality. I see in OWS.js that calls made via iFrame don't call the CleanUp() method so this doesn't look like it would work if iFrames are used (although this might be an easy change to support IFrame calls too.)

I'll post what I have anyway in the event anyone is interested. This would be placed in the CONTROL.HEADER section between HTML SCRIPT tags.

WARNING: I haven't tested this completely but it seems to work so-far.

 QueuedFetches.js.txt
New Post
3/7/2014 5:29 AM
 
Hi bbeswick , I tryed your script in my application, and It works great, in Chrome, but not in Firefox. Is there any fix about that?? I hope you will see this message. thank you
New Post
6/4/2014 1:42 AM
 
pinna wrote:
Hi bbeswick , I tryed your script in my application, and It works great, in Chrome, but not in Firefox. Is there any fix about that?? I hope you will see this message. thank you

 Hi pinna,

 

you use an old script. bbeswick has build a new one, that you can find here:

http://www.openwebstudio.com/Community/Forums/tabid/55/forumid/1/postid/26848/scope/posts/Default.aspx

 

by. richard

Previous
 
Next
HomeHomeCoreCoreGeneralGeneralCallbacks when AJAX call is completeCallbacks when AJAX call is complete


 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seattle, WA • info@openwebstudio.com

Bookmark & Share Bookmark and Share