Problem with responseText in Safari, Chrome and IE

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2008
Posts: 2
Reputation: melektaus55 is an unknown quantity at this point 
Solved Threads: 0
melektaus55 melektaus55 is offline Offline
Newbie Poster

Problem with responseText in Safari, Chrome and IE

 
0
  #1
Nov 18th, 2008
I have problem with the responseText property in Safari, Google Chrome and IE. Line 68 - the responseText is empty. This works fine in Firefox and Opera. Also i have this problem with the responseText only in the block that starts at line 61. I don't have problem with the responseText in other places in the source code. Please try to understand the last three sentences,i'm saying that because there are many people that reads only the first sentence and gives some absolutelly useless answer. Ok,i'll say it again anyway - this works fine in Firefox and Opera - the responseText has some value so everything is fine, but it doesn't have value(it's empty) in Safari, Chrome and IE. I don't see problem with my code,what's wrong?

Here is the code.
Last edited by melektaus55; Nov 18th, 2008 at 4:35 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,581
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 461
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Problem with responseText in Safari, Chrome and IE

 
0
  #2
Nov 22nd, 2008
That code is a big mess; just to confirm whether this is a problem with your code or responseText on IE strip all the fluff and create a bare minimum snippet which just sends a single parameter and receives some random response in responseText. If it still doesn't work, post the minimized code [without your application logic] along with which version of IE/Chrome you are having problems with.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 1
Reputation: crokusek is an unknown quantity at this point 
Solved Threads: 0
crokusek crokusek is offline Offline
Newbie Poster

Re: Problem with responseText in Safari, Chrome and IE

 
0
  #3
Jul 11th, 2009
Hi!

Looks like I'm running into similar problem the previous poster had run into..

I am receiving an empty response when calling a web method using asp.net in Chrome but not IE nor FF. I get this behavior using the ASP PageMethod.func as well as using jquery ajax call.

I can 'fix' the symptom by adding a delay sleep call on the server which makes me believe code is just plain wrong somewhere. I have the webkit fix so that Chrome is using webkit (see first line of log).

I have created a near minimal test case. The log of pressing each button from left to right is shown. Basically with out a sleep call on the server the load fails > 95% of the time. With a sleep(0) call its 50% and with a large sleep 1 sec it rarely (if ever?) fails.

If I remove the sleep and turn on Fiddler it never fails. Something like the response not getting flushed??

Is there something obviously wrong with the test case or is this a bug.

Thanks!!
Chris

Log:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. 0: Sys.Browser: [object Object], 530.5, WebKit
  2. 1: btnA -1
  3. 2: waiting for response now
  4. 3: btnJQA -1
  5. 4: waiting for response now
  6. 5: Result = EMPTY, textStatus =success
  7. 6: btnA 0
  8. 7: waiting for response now
  9. 8: Result = OnClick(.NET, page method, 0): 82 7/10/2009 1:01:01 PM
  10. 9: btnJQA 0
  11. 10: waiting for response now
  12. 11: Result = EMPTY, textStatus =success
  13. 12: btnA 1000
  14. 13: waiting for response now
  15. 14: Result = OnClick(.NET, page method, 1000): 84 7/10/2009 1:01:07 PM
  16. 15: btnJQA 1000
  17. 16: waiting for response now
  18. 17: Result = {"d":"OnClick(jquery, ajax, 1000): 85 7/10/2009 1:01:12 PM"}


Page Code:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxTest.aspx.cs" Inherits="PA.AjaxTest" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head id="Head1" runat="server">
  5. <title></title>
  6. <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
  7. <script type="text/javascript">
  8.  
  9. var iCount = 0;
  10. function log(s) {
  11. var l = $('#taLog');
  12. l.get()[0].value += iCount++ + ': ' + s + '\n';
  13. l.attr({ scrollTop: l.attr("scrollHeight") });
  14. }
  15.  
  16. function btnA_Click(iMilliSec) {
  17. log("btnA " + iMilliSec);
  18. PageMethods.OnClick(".NET", "page method", iMilliSec,
  19. function(result, userContext, methodName) {
  20. log('Result = ' + ((result != null) ? result : 'result was null'));
  21. },
  22. function(error, userContext, methodName) {
  23. log('PM Response Error: ' + (error != null ? error.get_message() : "no_msg") + '\n\t' + userContext + '\n\t' + methodName);
  24. });
  25.  
  26. log("waiting for response now");
  27. }
  28.  
  29. function json_parse(data) {
  30. return (typeof (JSON) !== 'undefined' && typeof (JSON.parse) === 'function') ? JSON.parse(data) : eval('(' + data + ')');
  31. }
  32.  
  33. function btnJQA_Click(iMilliSec) {
  34. log("btnJQA " + iMilliSec);
  35. $.ajax({
  36. type: "POST",
  37. url: "AjaxTest.aspx/OnClick",
  38. data: "{'s1': 'jquery', 's2': 'ajax', 'iMilliSec': '" + iMilliSec + "'}",
  39. timeout: 3000,
  40. cache: false,
  41. async: true,//false,
  42. //Connection: 'close',
  43. contentType: "application/json; charset=utf-8",
  44. //dataType: "json", bypass eval of response for now
  45. dataFilter: function(data) {
  46. return data;
  47. },
  48. success: function(msg, textStatus) {
  49. log('Result = ' + (msg == '' ? 'EMPTY, textStatus =' + textStatus : msg));
  50. },
  51. error: function(XMLHttpRequest, textStatus, errorThrown) {
  52. log('Got an error = ' + (textStatus != null) ? textStatus : "no textstatus");
  53. }
  54. });
  55. log("waiting for response now");
  56. }
  57.  
  58. function btnLoopA_Click() {}
  59. function btnLoopJQA_Click() { }
  60.  
  61. </script>
  62.  
  63. </head>
  64. <body>
  65. <form id="form1" runat="server">
  66. <div>
  67. <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
  68. <Scripts>
  69. <asp:ScriptReference Path="~/js/webkit.js" />
  70. </Scripts>
  71. </asp:ScriptManager>
  72.  
  73. <input id="btnA" type="button" value="btnA" onclick='btnA_Click(-1)'/>
  74. <input id="btnJQA" type="button" value="btnJQA" onclick='btnJQA_Click(-1)'/>
  75. <input id="btnA_S0" type="button" value="btnA_0_sec" onclick='btnA_Click(0)'/>
  76. <input id="btnJQA_S0" type="button" value="btnJQA_0_sec" onclick='btnJQA_Click(0)'/>
  77. <input id="btnA_S1" type="button" value="btnA_1_sec" onclick='btnA_Click(1000)'/>
  78. <input id="btnJQA_S1" type="button" value="btnJQA_1_sec" onclick='btnJQA_Click(1000)'/>
  79. <input id="btnLoopA" type="button" value="btnLoopA" onclick='btnLoopA_Click()'/>
  80. <input id="btnLoopJQA" type="button" value="btnLoopJQA" onclick='btnLoopJQA_Click()'/>
  81.  
  82. <textarea id="taLog" cols="120" rows="15" style='position: fixed; left: 10px; bottom: 10px; right: 10px'></textarea>
  83.  
  84. <script type="text/javascript">
  85. log('Sys.Browser: ' + Sys.Browser.agent + ", " + Sys.Browser.version + ", " + Sys.Browser.name);
  86. </script>
  87. </div>
  88. </form>
  89. </body>
  90. </html>

Server Code
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Web;
  3. using System.Web.UI;
  4. using System.ServiceModel.Web;
  5. using System.Web.Services;
  6.  
  7. namespace PA
  8. {
  9. public partial class AjaxTest : System.Web.UI.Page
  10. {
  11. protected void Page_Load(object sender, EventArgs e) {}
  12. static int __iCounter = 0;
  13. [WebMethod]
  14. public static string OnClick(string s1, string s2, int iMilliSec)
  15. {
  16. if (iMilliSec >= 0)
  17. System.Threading.Thread.Sleep(iMilliSec);
  18.  
  19. string sRet = "OnClick(" + s1 + ", " + s2 + ", " + iMilliSec + "): " + __iCounter + " " + DateTime.Now.ToString();
  20. __iCounter++;
  21.  
  22. return sRet;
  23. }
  24. }
  25. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC