1

this is my jquery code:

<script type="text/javascript">
    $(document).ready(function () {
        $("a").hover(function () {

            $.ajax({
                type: "POST",
                url:"Dbread.aspx",

                data: "name=salam",
                success: function (result) {
                    alert(result);


                } //end of success




            });


        }, function () {



        });


    });

</script>

in Dbread.aspx i wrote:

      string str= Request.QueryString["name"];
    Response.Write(str);

but the problem is that query string result is null all times!!! what is problem?

3 Answers 3

1

This is the best practice.

$.ajax({
    type: "POST",
    url:"Dbread.aspx",
    data: {name:"salam",qs:"bla"},  //also i appended the qs parameter
    success: function (result) {
        alert(result);

    } //end of success
});
Sign up to request clarification or add additional context in comments.

Comments

0

You are using method "POST" and not providing actual query string. Query string is created only for "GET" method and should be the part of the URL, so the fix would be:

$.ajax({
    type: "GET",
    url:"Dbread.aspx?name=salam",
    ...

or

$.ajax({
    type: "GET",
    url:"Dbread.aspx",
    data: "name=salam",
    ...

1 Comment

that's right. thanks.please excuse me for this stupid mistake
0

extra space can cause this problem

PrintPreview.NavigateUrl = "~/ReportViewer.aspx?ReviewID=" + Session["ArticleID"].ToString() + " & User=" + (Session["ID"]).ToString();

above is not working it returns null in ID

but in the below example it works fine just change of space character

PrintPreview.NavigateUrl = "~/ReportViewer.aspx?ReviewID= " + Session["ArticleID"].ToString() + "&User=" + (Session["ID"]).ToString();

http://afzal-gujrat.blogspot.com/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.