JavaScript How to intercept webserver response in Javascript function

Here's my predicament. In my JSP, I am trying to upload a file which in turns goes to a JS function. In my JS function, a dynamic iframe is being created, and has an onload function. The onload function creates a dynamic form element and goes on to submit it.

The underlying web server is IIS and if the file size is large, it throws an HTTP Error 404.13 and I get an HTML response. I want to be handle this and am unwilling to parse the HTML to look for error code. Kindly suggest how I should proceed.

My code looks something like this:

JSP content

<td>
<input type="image" id="uploadfile" src="../images/abc.gif" alt="Upload file" title="Upload File" />
<script type="text/javascript">
    var uploadfile = document.getElementById('uploadfile');
    upload({
        element : uploadfile,
        action : 'upload.jsp',
        onstart : function(filename) {
            document.getElementById("uploaded_file").innerHTML = "Uploading";
        },
        oncomplete : function(response_data) {
            .......//some logic
        }
    });
</script>
</td>

JS content

function upload(d) {
    var g = {
        element : null,
        action : "about:blank",
        action_params : {},
        maxsize : 0,
        onstart : null,
        oncomplete : null,
        dataname : "Filedata",
        target : null,
        zindex : "auto"
    };
    .......//some logic
    var c = document.createElement("div");
    .......//some logic
    c.innerHTML = '<iframe name="frameName" src="about:blank" onload="this.onload_callback()"></iframe>';
    .......//some logic
    var i = c.childNodes[0];
    i.onload_callback = function() {
        .......//some logic
        var a = document.createElement("form");
        .......//some logic
        a.submit();
    }
    .......//some logic
}
Answer:1

Can I prevent the user from highlighting one column in a table? I have a 2-column table. Users will want to copy the content in the second column, but not the first column. <table> <tr&...

Can I prevent the user from highlighting one column in a table? I have a 2-column table. Users will want to copy the content in the second column, but not the first column. <table> <tr&...

  1. make only one column editable in datagridview
  2. make read only column excel
  3. how to make one column editable in datagridview c#

I have a nodeJSON string like { "Name": "Addition", "Id": "3", "ParentId": "1", "children": [ { "Name": "Two Numbers", "Id": "5", "ParentId": "3", "children": [] ...

I have a nodeJSON string like { "Name": "Addition", "Id": "3", "ParentId": "1", "children": [ { "Name": "Two Numbers", "Id": "5", "ParentId": "3", "children": [] ...

  1. parse json string java
  2. parse json string c#
  3. parse json string python
  4. parse json string to object
  5. parse json string javascript
  6. parse json string online
  7. parse json string to object java
  8. parse json string to object c#
  9. parse json string golang
  10. parse json string ruby
  11. parse json string to dictionary python
  12. parse json string swift
  13. parse json string scala
  14. parse json string to map
  15. parse json string php
  16. parse json string to map java
  17. parse json string nodejs
  18. parse json string into object java
  19. parse json string into object javascript
  20. parse json string in sql

I have 3 people's birthdays: Steve -> May 3 Mark -> October 20 Robbin -> December 5 How to loop through the remaining days of the year and find which person still has a birthday coming (IN THIS ...

I have 3 people's birthdays: Steve -> May 3 Mark -> October 20 Robbin -> December 5 How to loop through the remaining days of the year and find which person still has a birthday coming (IN THIS ...

I'm trying to load an external script while using Meteor. Currently using this code in my layout.js to some success. Meteor.startup( function() { $.getScript('js/scripts.js'); }); However, if I go ...

I'm trying to load an external script while using Meteor. Currently using this code in my layout.js to some success. Meteor.startup( function() { $.getScript('js/scripts.js'); }); However, if I go ...

  1. jquery loading external html