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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How can access the arguments sent by (JavaScript request) ajax ?

How can access the arguments sent by (JavaScript request) ajax ?

Scheduled Pinned Locked Moved C#
helpquestioncsharpjavascriptasp-net
4 Posts 3 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.
  • D Offline
    D Offline
    dipak dipak
    wrote on last edited by
    #1

    Hello everybody, I have created a javascript (ajax) making a request to the server for save the infomation i have passed as arguments with the request. like this var args = "id=" + ID + "&name=" + Name + "&sex=" + Sex + "&age=" + Age; xmlHttp.open("POST","SaveInfo.aspx",true); xmlHttp.onreadystatechange = function theStateChanged() { if (xmlHttp.readyState==4 && xmlHttp.status==200) { alert("Successfully Saved"); } } xmlHttp.Send(args); these are OK. but i want to catch the args from my asp.net webpage. When i am using GET method for request, i am sending arguments by query string, and in .net page i can access that using Response.QuerySting["key1"].ToString(); But this time i am getting problem. how can i access the arguments passed. Please help me. Thanks in advance for help.

    Dipak

    C 1 Reply Last reply
    0
    • D dipak dipak

      Hello everybody, I have created a javascript (ajax) making a request to the server for save the infomation i have passed as arguments with the request. like this var args = "id=" + ID + "&name=" + Name + "&sex=" + Sex + "&age=" + Age; xmlHttp.open("POST","SaveInfo.aspx",true); xmlHttp.onreadystatechange = function theStateChanged() { if (xmlHttp.readyState==4 && xmlHttp.status==200) { alert("Successfully Saved"); } } xmlHttp.Send(args); these are OK. but i want to catch the args from my asp.net webpage. When i am using GET method for request, i am sending arguments by query string, and in .net page i can access that using Response.QuerySting["key1"].ToString(); But this time i am getting problem. how can i access the arguments passed. Please help me. Thanks in advance for help.

      Dipak

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Please don't cross post. The httpRequest object has properties like responseText that you can use to get data back from the server.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      D 1 Reply Last reply
      0
      • C Christian Graus

        Please don't cross post. The httpRequest object has properties like responseText that you can use to get data back from the server.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        D Offline
        D Offline
        dipak dipak
        wrote on last edited by
        #3

        Thanks for reply. I just need to get data "POST" from the client side (by javascript with send method) in the page asp.net page with C# code. var xmlHttp = GetXmlHttpObject(); xmlHttp.open("POST","SaveInfo.aspx",true); var args = "id=" + ID + "&name=" + Name + "&sex=" + Sex + "&age=" + Age; xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", args.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.onreadystatechange = function theStateChanged() { alert(xmlHttp.status); if (xmlHttp.readyState==4 && xmlHttp.status==200) { alert("Successfully Saved"); } } xmlHttp.Send(args); So, this is the code. I want to access the args from the page SaveInfo.aspx . how can access that to save those on the database using C# code on this page. Please help me.

        Dipak

        L 1 Reply Last reply
        0
        • D dipak dipak

          Thanks for reply. I just need to get data "POST" from the client side (by javascript with send method) in the page asp.net page with C# code. var xmlHttp = GetXmlHttpObject(); xmlHttp.open("POST","SaveInfo.aspx",true); var args = "id=" + ID + "&name=" + Name + "&sex=" + Sex + "&age=" + Age; xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", args.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.onreadystatechange = function theStateChanged() { alert(xmlHttp.status); if (xmlHttp.readyState==4 && xmlHttp.status==200) { alert("Successfully Saved"); } } xmlHttp.Send(args); So, this is the code. I want to access the args from the page SaveInfo.aspx . how can access that to save those on the database using C# code on this page. Please help me.

          Dipak

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          dipak.dipak wrote:

          So, this is the code. I want to access the args from the page SaveInfo.aspx . how can access that to save those on the database using C# code on this page.

          Request.QueryString

          xacc.ide - now with IronScheme support
          IronScheme - 1.0 alpha 2 out now

          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