Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Standard AJAX callback too big and slow on large datasets, trying to write my own

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • peteconway
    replied
    Re: Standard AJAX callback too big and slow on large datasets, trying to write my own

    Well done Luke, I can only hope your methods make their way into the product along with the recondition for your contribution. Really great stuff mate.

    Leave a comment:


  • Steve Workings
    replied
    Re: Standard AJAX callback too big and slow on large datasets, trying to write my own

    Nice job, and congrats. Spending a couple days on something like can be hard to do, but the payoff - both in this use and future implementations. And, good of you to share the code.

    Leave a comment:


  • LukeS
    replied
    Re: Standard AJAX callback too big and slow on large datasets, trying to write my own

    I got it working and it is lighting fast! It has cut my callback time from ~40-50 seconds down to under a second!!!!!!! Here is how I did it..

    On my dialog an user can enter a product number of a item they want to add or use a lookup grid, that number in placed in the N_product number textbox. Then the user will have to click the add item button to add the item to the dialog repeating section, this button calls the AJAXcallbackAddNewItem() function which fires off a custom AJAX callback to add the item to the DB table then returns the ID and sort placement value.

    Dialog javascript code to add new item to repeating section with AJAX callback, AJAXcallbackAddNewItem() is called to add a new item and start the callback.
    Code:
    function hideMsg() {
    	A5.msgBox.hide();
    }
    
    
    function hideMsgWnote(note) {
    	A5.msgBox.hide();
    	alert(note);
    }
    
    
    function afterAJAXcallbackAddNewItem(oRData,status) {
    	var activeRowNum;	//Current Active Row
    	
    	//alert(status);
    	//alert(oRData.nReturnedStatus);
    	
    	/* --- If sucessfull --- */
    	if (oRData.nReturnedStatus === 1) {
    		{dialog.Object}.addRepeatingSectionRow('RS1');
    		activeRowNum = {dialog.Object}.getRepeatingSectionActiveRow('RS1');
    		
    		/* -- Move data from previous product lookup from tmp fields to new repeating section row -- */
    		{dialog.Object}.setValue('RS_ID:' + activeRowNum,oRData.nID)
    		{dialog.Object}.setValue('RS_SP:' + activeRowNum,oRData.nSortPlacement)
    		{dialog.Object}.setValueFrom('RS_A:' + activeRowNum,'N_ACTIVE')
    		{dialog.Object}.setValueFrom('RS_PN:' + activeRowNum,'N_PRODUCT_NUM')
    		{dialog.Object}.setValueFrom('RS_D:' + activeRowNum,'N_DESCRIPTION')
    		{dialog.Object}.setValueFrom('RS_S:' + activeRowNum,'N_SIZE')
    		{dialog.Object}.setValueFrom('RS_B:' + activeRowNum,'N_BTPC')
    		{dialog.Object}.setValueFrom('RS_Q:' + activeRowNum,'N_QTYC')
    		{dialog.Object}.setValue('RS_QC:' + activeRowNum,0)
    		{dialog.Object}.setValue('RS_QB:' + activeRowNum,0)
    
    		hideMsg(); //Hides adding new record A5 message
    	}
    	else if (oRData.nReturnedStatus === 3) {
    		hideMsgWnote('You did not enter a product number to add, no item will be added');
    	}
    	else if (oRData.nReturnedStatus === 4) {
    		hideMsgWnote('Invalid product number');
    	}
    	else if (oRData.nReturnedStatus === 5) {
    		hideMsgWnote('Item already exist on order guide, item will not be added again');
    	}
    	else {
    		hideMsgWnote('Unknown error occurred, item will not be added, status code: ' + oRData.nReturnedStatus);
    	}
    }
    
    
    function AJAXcallbackAddNewItem() {
    	var account_num;
    	var product_num;
    	
    	A5.msgBox.show('Adding item...','Please wait while this new item is being added.','none',function() {});
    
    	account_num = {dialog.Object}.getValue('ACCOUNT_NUM');
    	product_num = {dialog.Object}.getValue('N_PRODUCT_NUM');
    
    	jQuery.ajax({
    		type: "GET",
    		url: "AJAX_callback_order_guide_add_item.a5w",
    		processData: false,
    		dataType: "json",
    		data: 'account_num=' + account_num + '&product_num=' + product_num,
    		success: afterAJAXcallbackAddNewItem});	
    }
    Here is the code for the AJAX callback URL page. The function this page calls returns a pointer dot var that contains the data that will be populated to a JSON var for the callback to read.
    Code:
    <%a5
    	DIM pResult	AS P
    	DIM pResult.nReturnedStatus AS N
    
    	'------------------------------------------------------------
    	' - Check to make sure required data was passed in to page -
    	'------------------------------------------------------------
    	if (.NOT. variable_exists("request.variables.account_num")) then
    		pResult.nReturnedStatus = 2
    		GOTO RETURN_STATUS
    	end if
    	
    	if (.NOT. variable_exists("request.variables.product_num")) then
    		pResult.nReturnedStatus = 3
    		GOTO RETURN_STATUS
    	end if
    
    	'--------------------------------------------------
    	' - Call function to add new item to order guide -
    	'--------------------------------------------------
    	pResult = GH_Add_Item_to_OrdGuide(request.variables.account_num,request.variables.product_num)
    	
    
    	'------------------------------------------------
    	' - Pass returned status back to AJAX callback -
    	'------------------------------------------------
    	'Dump status data to JSON object for AJAX callback to read
    	RETURN_STATUS:
    	?json_generate(pResult)
    
    %>
    Last edited by LukeS; May 29, 2012, 12:41 AM. Reason: spelling

    Leave a comment:


  • LukeS
    replied
    Re: Standard AJAX callback too big and slow on large datasets, trying to write my own

    Slowly progressing here.. I have having issues with jQuery when using it on a a5w page that has a dialog, I can get the ajax callback object of jQuery to work if I use it on a blank a5w page and include the following within the HTML head tag
    Code:
    <script type="text/javascript" src="javascript/A5jQuery.js"></script>
    or
    <script type="text/javascript" src="javascript/A5jQueryWithUI.js"></script>
    My dialog automatically adds the include A5jQueryWithUI.js in the HTML head when the page is loaded in the browser, so I am not including it again. When I try and make a call to the jQuery AJAX object it does not work and the JavaScript console in chrome gives the following error; it can not find the .ajax object in jQuery.
    A5jQuery_javscript_error.PNG

    Here is my JavaScript code that is under JavaScript functions in my dialog, this function works in a blank a5w page with the A5jQuery.js or A5jQueryWithUI.js referenced in the html head tag
    Code:
    function AJAXcallbackAddNewItem() {
    	$.ajax({
    		type: "GET",
    		url: "AJAX_callback_order_guide_add_item.a5w",
    		success: test2});
    }
    Has anyone use the built in jQuery in A5, is there any tricks to get it to work?

    Edit: I figured it out! You have to reference jQuery for example jQuer.ajax(), you can not use the standard "$" reference, this must be used my A5's JavaScript libraries
    Last edited by LukeS; May 28, 2012, 02:16 PM.

    Leave a comment:


  • Steve Workings
    replied
    Re: Standard AJAX callback too big and slow on large datasets, trying to write my own

    I don't have the details for your answer right away.

    I will note that just because you don't see jQuery.js files doesn't mean it's not there.

    Here's some page source from one of my pages:

    <script type="text/javascript" src="javascript/a5-25493903.js"></script>
    <script type="text/javascript" src="javascript/a5_url.js"></script>
    <script type="text/javascript" src="javascript/A5jQueryWithUI.js"></script>
    <script type="text/javascript" src="javascript/iscroll.js"></script>
    <script type="text/javascript" src="javascript/a5_igallery.js"></script>


    You won't find all these .js files, but the server sees them and knows what to do with them. It's a great way to keep the library up to date - let Alpha do it.

    At least that's what I think I understand...

    Leave a comment:


  • LukeS
    replied
    Re: Standard AJAX callback too big and slow on large datasets, trying to write my own

    Thanks a lot for the response Steve. The "cReturnedStatus" was not the best example of what I am trying to accomplish. I need the AJAX callback to return JavaScript, like the standard A5 AJAX callback does, so I can call a JavaScript function on the dialog to add a repeating section row. See the first case, if nReturnStatusCode == 1, it will not just be alerts or message boxes. I also want to take this one step further and write my own JavaScript to go through the dialog and only submit select data feilds from dirty rows of the dialog instead of submitting the whole dialog thus bypassing the dialog submit action which is taking far too long currently.

    I have started doing a lot of reading today on jQuery and right now I am at the "whoa, this is overwhelming stage" but I think I will get over the hump shortly here. Form what I know now, which granted is not much yet, it seems jQuery is a good way of getting returned data from AJAX callbacks as it can handle many different data objects like JSON for example and A5 have a Xbasic function that can parse data to a JSON objects which I can use on the callback URL page.

    This Wiki Page says the jQuery JavaScript library should be automatically placed in the "javascript/A5jQuery.js" folder if the project settings are set to use the internally stored versions of jQuery which is how my project is setup. There are no files with jQuery in the name in my projects javascript folder after publish, am I missing something really basic here.

    Leave a comment:


  • Steve Workings
    replied
    Re: Standard AJAX callback too big and slow on large datasets, trying to write my own

    Luke - I just did something like this today. A bunch of work to get it straight, but invisible speed so you're on the right track -- or at least on a right track.

    I'm not sure what you want to do at the end with cReturnStatus. Are you just stuck for way to display the message as required?

    If that's the case, why not just do something like this:

    Code:
    elseif (nReturnStatusCode == 3) then
    		alert('You did not enter a product number to add, no item will be added');
    While you're at it, or for 2nd round later, I'll encourage you to check out the A5.msgBox.show() javascript function in A5. Here's an example:

    Code:
    function abox(msg)
    {
    var title = 'Instruction:';
    var l1 = '<div Class=\'MobBlueGrid\' style=\'position:  relative; width:  300px; height:  225px; padding:10px \'>';
    var l2 = '<img src=\'imgs/Logo_oerca.jpg\' style=\'float:center;\'/><br /><br />';		
    var l3 = msg;
    var l4 = '</div>';
    msg = l1 + l2 + l3 + l4;
    A5.msgBox.show(title, msg,'o',function(){});
    }

    Leave a comment:


  • Standard AJAX callback too big and slow on large datasets, trying to write my own

    I have a dialog with a repeating section that can get as big as about 300 items... I know what you are thinking, "why would you ever do that?" For that answer see the background information below. AJAX callbacks on are taking over a minute to complete in some larger data sets due to the sheer size of the callback. It seems most of this time is the A5 application server parsing the callback as I wrote a test function that takes a few milliseconds to run and it still took 40 seconds to do the callback. I would like to avoid all this and just write my own callback that will only submit the needed data but am unsure about how to return data from the callback URL. If all goes well I plan to write my own submit callback too which will only submit the few editable fields on only rows that are dirty.



    Background Info (can be skipped):
    I will try to address why I am using such a large dialog repeating section without going into too much detail as why it is needed; people do not like to read long posts. The web app will be used by salesreps to place orders in retail stores that the company supplies (small wine distributor). Products are not laid out in retail stores in alphabetical or numerical order. The salesreps have to be able to set their own custom item sort order so they can "walk the shelves" and simply go down the list of products as they appear in the store. To do this I have created a sort placement field in the DB table that contains the items each account (store) orders; this is called a order guide. When a new record is added to the order guide table the sort number is auto assigned the value of ID field which places the item at the bottom of the order guide, the id is auto assigned and never changes. Now we get to the problem; being able to quickly move items around in a order guide has been a issue. If you use a multi-page grid you cannot move items up or down without a Ajax callback to change the sort placement value then refresh the grid. This takes a few seconds on each move and quickly gets extremely annoying on large order guides (200+ items). I have tried a ton on things and found the fastest is to just allow the user to do all the moving in a dialog repeating section with JavaScript swapping the sort values and row placements then just submit the data when they are done. Now the problem becomes the sheer size of the callback on dialog submit. There are a few cases where a callback is still needed outside of the submit that are a problem too, adding and removing items. When an item is added a callback is needed to execute code that adds an item and returns the new ID and sort placement value, this callback is submitting all the grid data which is a total waste, all I need is the account number and the new product number.

    Times to process a dialog with a repeating section of 250 items:
    - Initial load of dialog: 4-8 seconds
    - Submit (AJAX Callback): 50 seconds
    - Add item in repeating section (AJAX Callback to get id and sort placement value): ~40-50 seconds
    - Delete item in repeating section (Submit AJAX callback then page refresh): ~50-60 seconds
    - Simple AJAX callback, I am calling function that creates a file as a marker on the server, then the code on the server returns a basic JavaScript alert, only a few lines of code total: 42 seconds
    -- Breakdown timing of above.
    --- Time from AJAX callback button press to server CPU jumping to 100% (callback data submit time): 5 seconds
    --- Time from server CPU at 100% to file being created: 20 seconds
    --- Time from file being created until server cpu drops from 100% / JavaScript alert message appears: 17 seconds




    Here is what I have so far

    JavaScript on dialog to submit AJAX callback for adding a new item to the repeating section:
    Code:
    function AJAXcallAddNewItem() {
    	var account_num;
    	var product_num;
    	
    	account_num = {dialog.Object}.getValue('ACCOUNT_NUM');
    	product_num = {dialog.Object}.getValue('N_PRODUCT_NUM');
    	
    	A5.ajax.callback('AJAX_callback_order_guide_add_item.a5w','account_num=' + account_nume + '&product_num=' + product_num);
    }
    "AJAX_callback_order_guide_add_item.a5w" page code:
    Code:
     
    <%a5
    	DIM nReturnStatusCode AS N
    	DIM cReturnStatus	AS C
    
    	'------------------------------------------------------------
    	' - Check to make sure required data was passed in to page -
    	'------------------------------------------------------------
    	if (.NOT. variable_exists("request.variables.account_num")) then
    		nReturnStatusCode = 2
    		GOTO RETURN_STATUS
    	end if
    	
    	if (.NOT. variable_exists("request.variables.product_num")) then
    		nReturnStatusCode = 3
    		GOTO RETURN_STATUS
    	end if
    
    	'--------------------------------------------------
    	' - Call function to add new item to order guide -
    	'--------------------------------------------------
    	DIM pResult	AS P
    	pResult = GH_Add_Item_to_OrdGuide(e.dataSubmitted.ACCOUNT_NUM,e.dataSubmitted.N_PRODUCT_NUM)
    	nReturnStatusCode = pResult.nReturnedStatus
    
    	RETURN_STATUS:
    	
    	if (nReturnStatusCode == 1) then 
    		cReturnStatus = "addNewItem(" + nReturnStatusCode + ");"
    	elseif (nReturnStatusCode == 3) then
    		cReturnStatus = "alert('You did not enter a product number to add, no item will be added');"
    	elseif (nReturnStatusCode == 4) then
    		cReturnStatus = "alert('Item already exist on order guide, item will not be added again');"
    	else
    		cReturnStatus = "alert('Unkown error occured, item will not be added, status code: " + nReturnStatusCode + "');"
    	end if
    
    
    	'------------------------------------------------
    	' - Pass returned status back to AJAX callback -
    	'------------------------------------------------
    	'??? What should I do here?  How do I make the callback read the value of the "cReturnStatus" var?  
    	' Does "cReturnStatus" need to be in a div or XML container that I specify in the callback to read?
    	'?cReturnStatus
    
    %>
    I found some info on the wiki, this page says you can use the $gvs function to grab data from the callback url page but not really sure what type of container to put the data in, etc. I am hopping someone out there has already done something similar and would be willing to share some code snippets of the callback URL page code.
    Last edited by LukeS; May 28, 2012, 10:46 AM.
Working...
X