Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. The responseText property of XMLHttpRequest object is returning the whole HTML page

The responseText property of XMLHttpRequest object is returning the whole HTML page

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthtmlasp-netdatabase
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AumSingh
    wrote on last edited by
    #1

    Hello all, I am a newbie to the AJAX programming techniques. I want to update my database as per choice made by the user and inform him/her about the same if the updation has been done successfully. The platform is ASP.NET Following is my implementation: The file containing following two javascript functions has been included in my ASPX file. This function (i.e. submitValue) is called on the button click and the parameter (i.e. value) is the data I want to update on my database. The function "getXmlHttp()" in bold is returning the required XMLHttpRequest object by using the suitable method as per the browser detected. As I want to inform the user on the same page so the variable "requestURL" passed in the open() function contains the URL of the same page with updated querystring. function submitValue(value) { try { //Create the XMLHttpRequest object. xmlHttp = getXmlHttp(); //Call the function to process the response from the server xmlHttp.onreadystatechange = stateChanged; //Send request to the server var requestURL = location.href+"&q="+value; xmlHttp.open('GET',requestURL,true); xmlHttp.send(null); } catch(e) { alert("Error : Sending request"); } } Following javascript function which is called above is used to process the server response. function stateChanged() { try { if (xmlHttp.readyState==4 ||xmlHttp.readyState=='complete') { var retValue; retValue = xmlHttp.responseText; if(retValue=="0") document.getElementById("divRateInfo").innerHTML = "Rating submition failed. Try again."; else document.getElementById("divRateInfo").innerHTML = "Rating successfully submited!"; } } catch(e) { alert("Error : Processing response"); } } Finally following is the code behind written on the corresponding ASPX.CS file. The method is called on the page load. private void SaveRating() { try { if (Request.QueryString["q"] != null) { int nUserRate = Convert.ToInt32(Request.QueryString["q"].ToString()); SqlParameter[] sqlParam = new SqlParameter[2]; sqlParam[0] = new SqlParameter("@rate", SqlDb

    S 1 Reply Last reply
    0
    • A AumSingh

      Hello all, I am a newbie to the AJAX programming techniques. I want to update my database as per choice made by the user and inform him/her about the same if the updation has been done successfully. The platform is ASP.NET Following is my implementation: The file containing following two javascript functions has been included in my ASPX file. This function (i.e. submitValue) is called on the button click and the parameter (i.e. value) is the data I want to update on my database. The function "getXmlHttp()" in bold is returning the required XMLHttpRequest object by using the suitable method as per the browser detected. As I want to inform the user on the same page so the variable "requestURL" passed in the open() function contains the URL of the same page with updated querystring. function submitValue(value) { try { //Create the XMLHttpRequest object. xmlHttp = getXmlHttp(); //Call the function to process the response from the server xmlHttp.onreadystatechange = stateChanged; //Send request to the server var requestURL = location.href+"&q="+value; xmlHttp.open('GET',requestURL,true); xmlHttp.send(null); } catch(e) { alert("Error : Sending request"); } } Following javascript function which is called above is used to process the server response. function stateChanged() { try { if (xmlHttp.readyState==4 ||xmlHttp.readyState=='complete') { var retValue; retValue = xmlHttp.responseText; if(retValue=="0") document.getElementById("divRateInfo").innerHTML = "Rating submition failed. Try again."; else document.getElementById("divRateInfo").innerHTML = "Rating successfully submited!"; } } catch(e) { alert("Error : Processing response"); } } Finally following is the code behind written on the corresponding ASPX.CS file. The method is called on the page load. private void SaveRating() { try { if (Request.QueryString["q"] != null) { int nUserRate = Convert.ToInt32(Request.QueryString["q"].ToString()); SqlParameter[] sqlParam = new SqlParameter[2]; sqlParam[0] = new SqlParameter("@rate", SqlDb

      S Offline
      S Offline
      sulabh2020
      wrote on last edited by
      #2

      Hi dear, Ur code is perfect for xmlhttp, may be there is some bug in the page where u r getting response.. try debug the code by direct opening the url with passed parameters u now can easily trace the bug if any..

      Hello Forum Always be in touch to help about the topic ASP.NET

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups