Can you use XMLHttpRequest to track large SQL update loop in code behind Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!MVC Progress Bar using http PostAjax Post Form - Difficulty Integrating XHR2 File Uploadajax upload using iframefile upload with progress barPassing file with filename and other parameters to upload files using jqueryFile upload in Ajax Contact Form doesn't work$_POSt returns unexpected arrayWordPress ajax file upload with jQueryHow to save 'multipart/form-data' (picture, pdf, and etc.) to mysql database mediumblob via jquery?Displaying each data line by line during AJAX CSV File Upload
Derived column in a data extension
Flight departed from the gate 5 min before scheduled departure time. Refund options
Did any compiler fully use 80-bit floating point?
An isoperimetric-type inequality inside a cube
Short story about astronauts fertilizing soil with their own bodies
Is the Mordenkainens' Sword spell underpowered?
Where did Ptolemy compare the Earth to the distance of fixed stars?
Does a random sequence of vectors span a Hilbert space?
Who said what about *meanings*?
What did Turing mean when saying that "machines cannot give rise to surprises" is due to a fallacy?
How do you write "wild blueberries flavored"?
Order between one to one functions and their inverses
How to make an animal which can only breed for a certain number of generations?
Should man-made satellites feature an intelligent inverted "cow catcher"?
Does the universe have a fixed centre of mass?
Is the time—manner—place ordering of adverbials an oversimplification?
How could a hydrazine and N2O4 cloud (or it's reactants) show up in weather radar?
First paper to introduce the "principal-agent problem"
Centre cell vertically in tabularx
Keep at all times, the minus sign above aligned with minus sign below
Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?
Besides transaction validation, are there any other uses of the Script language in Bitcoin
How to achieve cat-like agility?
Can two people see the same photon?
Can you use XMLHttpRequest to track large SQL update loop in code behind
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!MVC Progress Bar using http PostAjax Post Form - Difficulty Integrating XHR2 File Uploadajax upload using iframefile upload with progress barPassing file with filename and other parameters to upload files using jqueryFile upload in Ajax Contact Form doesn't work$_POSt returns unexpected arrayWordPress ajax file upload with jQueryHow to save 'multipart/form-data' (picture, pdf, and etc.) to mysql database mediumblob via jquery?Displaying each data line by line during AJAX CSV File Upload
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I allow end users to upload a file, then read into memory, and loop through it to update data. I am wondering a way i can report progress of the SQL loop i do in C# back to the UI just like we do for the file upload. We use ajax POST, then read by line, so when doing larger reads, i want a progress status of how many lines we have read. Is this possible, or does this only work with upload / download streams of files.
Here is the ajax call that does the file upload, and while waiting for the AJAX to return a response, the file progress works great for the file being upload but not the loop tracking.
var form = $('#FormUpload')[0];
var dataString = new FormData(form);
$("#cboxClose").trigger("click");
$.ajax(
url: '/Uploader/Upload', //Server script to process data
type: 'POST',
xhr: function () // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) // Check if upload property exists
//myXhr.upload.onprogress = progressHandlingFunction
myXhr.upload.addEventListener('progress', progressHandlingFunction,
false); // For handling the progress of the upload
return myXhr;
,
//Ajax events
success: uploadSuccessHandler,
error: uploadErrorHandler,
//complete: completeHandler,
// Form data
data: dataString,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
);
}
Here is part of the C# controller from MVC i call, but i have limited and made logic general for purposes of this question.
try
{
if (uploadedFile != null && uploadedFile.ContentLength > 0)
if (uploadedFile != null)
if (uploadedFile.ContentLength > 0)
using (StreamReader sr = new StreamReader(uploadedFile.InputStream))
string currentLine;
int counterLine = 0;
// currentLine will be null when the StreamReader reaches the end of file
while ((currentLine = sr.ReadLine()) != null)
if (counterLine > 0)
String fixedLine = currentLine;
if (currentLine.Contains("/"))
fixedLine = currentLine.Remove('/');
string[] columns = fixedLine.Split(',');
quoteDataRows.Add(new QuoteEntityItemVM()
Manufacturer = columns[0],
Model = columns[2],
Description = columns[1],
LineID = lineCountId += 1
);
counterLine += 1;
Is there a way i can use modern AJAX to not only show progress of the uplaod, but while the counter loops report back progress to the UI something like ("Lines read (n) of total line (n)" back to the UI, or is this not possible?
-Thanks-
javascript jquery ajax xmlhttprequest
add a comment
Here is part of the C# controller from MVC i call, but i have limited and made logic general for purposes of this question.
try
{
if (uploadedFile != null && uploadedFile.ContentLength > 0)
improve this questionI allow end users to upload a file, then read into memory, and loop through it to update data. I am wondering a way i can report progress of the SQL loop i do in C# back to the UI just like we do for the file upload. We use ajax POST, then read by line, so when doing larger reads, i want a progress status of how many lines we have read. Is this possible, or does this only work with upload / download streams of files.
Here is the ajax call that does the file upload, and while waiting for the AJAX to return a response, the file progress works great for the file being upload but not the loop tracking.
var form = $('#FormUpload')[0];
var dataString = new FormData(form);
$("#cboxClose").trigger("click");
$.ajax(
url: '/Uploader/Upload', //Server script to process data
type: 'POST',
xhr: function () // Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) // Check if upload property exists
//myXhr.upload.onprogress = progressHandlingFunction
myXhr.upload.addEventListener('progress', progressHandlingFunction,
false); // For handling the progress of the upload
return myXhr;
,
//Ajax events
success: uploadSuccessHandler,
error: uploadErrorHandler,
//complete: completeHandler,
// Form data
data: dataString,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
);
Here is part of the C# controller from MVC i call, but i have limited and made logic general for purposes of this question.
try
{
if (uploadedFile != null && uploadedFile.ContentLength > 0)
{
if (uploadedFile != null)
if (uploadedFile.ContentLength > 0)
using (StreamReader sr = new StreamReader(uploadedFile.InputStream))
string currentLine;
int counterLine = 0;
// currentLine will be null when the StreamReader reaches the end of file
while ((currentLine = sr.ReadLine()) != null)
if (counterLine > 0)
String fixedLine = currentLine;
if (currentLine.Contains("/"))
fixedLine = currentLine.Remove('/');
string[] columns = fixedLine.Split(',');
quoteDataRows.Add(new QuoteEntityItemVM()
Manufacturer = columns[0],
Model = columns[2],
Description = columns[1],
LineID = lineCountId += 1
);
counterLine += 1;
Is there a way i can use modern AJAX to not only show progress of the uplaod, but while the counter loops report back progress to the UI something like ("Lines read (n) of total line (n)" back to the UI, or is this not possible?
-Thanks-
javascript jquery ajax xmlhttprequest
javascript jquery ajax xmlhttprequest
asked Mar 22 at 12:50
CaseyCasey
1,257822
1,257822
You could send request to your api to check how many lines has been read. Or you could configure a websocket code.msdn.microsoft.com/HTML-5-Web-Socket-e679d61d
– Benjamin
Mar 22 at 13:12
How do i send request to API and report that back if it is in different call? could you provide basic example? This is probably straight forward and im over looking this.
– Casey
Mar 22 at 13:16
Actually, i like the web-socket method, and forgot about it now in HTML5. Thanks and will try that out. Will post answer if i resolve it.
– Casey
Mar 22 at 13:19
Im not sure how i would send back integer count to UI using the web socket example show. I see you construct with context, but how do i feed to the "Message" event in my c# loop to write back to the socket?
– Casey
Mar 22 at 14:03
Unfortunately, c# is out of my scope, in java, you would call an object from the current session to pass the message, it should be similar in c#. You should take a look at the official documentation.
– Benjamin
Mar 25 at 9:47
add a comment |
You could send request to your api to check how many lines has been read. Or you could configure a websocket code.msdn.microsoft.com/HTML-5-Web-Socket-e679d61d
– Benjamin
Mar 22 at 13:12
How do i send request to API and report that back if it is in different call? could you provide basic example? This is probably straight forward and im over looking this.
– Casey
Mar 22 at 13:16
Actually, i like the web-socket method, and forgot about it now in HTML5. Thanks and will try that out. Will post answer if i resolve it.
– Casey
Mar 22 at 13:19
Im not sure how i would send back integer count to UI using the web socket example show. I see you construct with context, but how do i feed to the "Message" event in my c# loop to write back to the socket?
– Casey
Mar 22 at 14:03
Unfortunately, c# is out of my scope, in java, you would call an object from the current session to pass the message, it should be similar in c#. You should take a look at the official documentation.
– Benjamin
Mar 25 at 9:47
You could send request to your api to check how many lines has been read. Or you could configure a websocket code.msdn.microsoft.com/HTML-5-Web-Socket-e679d61d
– Benjamin
Mar 22 at 13:12
You could send request to your api to check how many lines has been read. Or you could configure a websocket code.msdn.microsoft.com/HTML-5-Web-Socket-e679d61d
– Benjamin
Mar 22 at 13:12
How do i send request to API and report that back if it is in different call? could you provide basic example? This is probably straight forward and im over looking this.
– Casey
Mar 22 at 13:16
How do i send request to API and report that back if it is in different call? could you provide basic example? This is probably straight forward and im over looking this.
– Casey
Mar 22 at 13:16
Actually, i like the web-socket method, and forgot about it now in HTML5. Thanks and will try that out. Will post answer if i resolve it.
– Casey
Mar 22 at 13:19
Actually, i like the web-socket method, and forgot about it now in HTML5. Thanks and will try that out. Will post answer if i resolve it.
– Casey
Mar 22 at 13:19
Im not sure how i would send back integer count to UI using the web socket example show. I see you construct with context, but how do i feed to the "Message" event in my c# loop to write back to the socket?
– Casey
Mar 22 at 14:03
Im not sure how i would send back integer count to UI using the web socket example show. I see you construct with context, but how do i feed to the "Message" event in my c# loop to write back to the socket?
– Casey
Mar 22 at 14:03
Unfortunately, c# is out of my scope, in java, you would call an object from the current session to pass the message, it should be similar in c#. You should take a look at the official documentation.
– Benjamin
Mar 25 at 9:47
Unfortunately, c# is out of my scope, in java, you would call an object from the current session to pass the message, it should be similar in c#. You should take a look at the official documentation.
– Benjamin
Mar 25 at 9:47
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55300022%2fcan-you-use-xmlhttprequest-to-track-large-sql-update-loop-in-code-behind%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55300022%2fcan-you-use-xmlhttprequest-to-track-large-sql-update-loop-in-code-behind%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You could send request to your api to check how many lines has been read. Or you could configure a websocket code.msdn.microsoft.com/HTML-5-Web-Socket-e679d61d
– Benjamin
Mar 22 at 13:12
How do i send request to API and report that back if it is in different call? could you provide basic example? This is probably straight forward and im over looking this.
– Casey
Mar 22 at 13:16
Actually, i like the web-socket method, and forgot about it now in HTML5. Thanks and will try that out. Will post answer if i resolve it.
– Casey
Mar 22 at 13:19
Im not sure how i would send back integer count to UI using the web socket example show. I see you construct with context, but how do i feed to the "Message" event in my c# loop to write back to the socket?
– Casey
Mar 22 at 14:03
Unfortunately, c# is out of my scope, in java, you would call an object from the current session to pass the message, it should be similar in c#. You should take a look at the official documentation.
– Benjamin
Mar 25 at 9:47