-1

I have a form within an aspx page,this form takes a file input and posts it to viddler server.

While the file gets posted to viddler server,In the backgorund i make ajax calls to a webmethod on the codebehind page, this webmethod calls the viddler server and returns the upload progress for that particular upload.

These Ajax calls are working fine in firefox, but not working in chrome,they are not even coming up in the chrome Network panel and none of these functions (success,error or complete) are firing.

Am i missing anything here?

Here is my ajax call:

    function checkProgress() {
        tokenValue = document.getElementById("uploadtoken").value;
        var y = "{ token: 'token' }";

        var jsonText = JSON.stringify({ token: tokenValue });

      $.ajax({
             type: 'POST',
             url: "video_viddlerUpload.aspx/CheckProgress",
             data: jsonText,
             contentType: 'application/json',
         dataType: 'json',
         cache: false,
         async: true,
         success: function(json) {

                var uploadProgress;
                uploadProgress = eval('(' + json.d + ')');


                   },
                 error: function (xmlHttpRequest, textStatus, errorThrown) {


             alert('There was an error uploading your file. Please try  again.');
          },
                complete:function () {
                    alert('complete');
                  }
    }); 

    } 

Please help me. I will be very helpful.

user3351001
  • 11
  • 1
  • 4
  • `var jsonText = JSON.stringify({ token: tokenValue });` not making sense.. – Ishank Feb 25 '14 at 12:05
  • it's same as var jsonText = "{"token":"u04d88"}"; that webmethod takes an input parameter called "token" – user3351001 Feb 25 '14 at 12:11
  • Are you ever calling your function `checkProgress()`? Also, I don't think you need to explicitly `stringify` your POST data. – Knelis Feb 25 '14 at 13:17
  • Then there should probably be some error message in Chromes Console – Sander_P Feb 25 '14 at 13:21
  • Yes i am calling checkProgress(), and there are no errors in console. However on the network panel there is a pending post to viddler server,as the file is being uploaded. would this pending post stop ajax calls? – user3351001 Feb 25 '14 at 14:36

1 Answers1

0

Guess the problem is with cache:false as the jQuery Doc says - " Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET." and u are doing a POST request.

Ishank
  • 2,860
  • 32
  • 43