开发者

posting with AJAX

I am pretty new new to Ajax and Jquery and trying tunderstand it. Well,开发者_C百科 I want to submit to the same page and then read the values.

I have something likes this which does not seem to work:

  $.ajax({
                type: "POST",
                url: "admin_fans.asp",                
                data: {
                    "IDCollection": sMemberIDCollection,
                    "task": "addnewmember"
                }
            })

and I am trying to read it on the page with something like this

if (Request("task")="") Then
    response.Write("after form submit")
    response.End()
End if

It does nothing. It is classic ASp by the way


You seem to be missing a semicolon on your last line.

}) to });


First thing, you should not put quotation marks on keys of your data

IDCollection: sMemberIDCollection,
task: "addnewmember"

second thing, check with firebug or fiddler if your ajax request is posting right data


you can use like this approach also

 var xmlhttp;
 if (window.XMLHttpRequest)
    {
     xmlhttp=new XMLHttpRequest();
     }
 else
    {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
    xmlhttp.onreadystatechange=function()
    {
       if (xmlhttp.readyState==4 && xmlhttp.status==200)
         {
        document.getElementById("results").innerHTML=xmlhttp.responseText;

        }
       } 
    var user = document.getElementById("userid").value; 
    var usernm = document.getElementById("username").value; 
    var pwd = document.getElementById("password").value; 
    var ath = document.getElementById("authority").value; 
    var email = document.getElementById("emailid").value; 
    var params = "user=" + user + "&usernm=" + usernm + "&pwd=" + pwd + "&ath=" + ath + "&email=" + email; 
       xmlhttp.open("POST","admin_fans.asp",true);
       xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
       xmlhttp.send(params); 

in this you can send values and store response in some control (in my example in 'results' div i am storing)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜