Hi All,

I'm new to this jquery and i found some article, implemented but its server side method is not firing. Plz if you know help out this probelm.

These is the code implemented in my application in jquery side.

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

                $("#btnClick").click(function() {
                    var email = $("#txtemail").val();
                    $.ajax({
                        type: "POST",
                        url: "TestingEmail.aspx/DNSValidation",
                        data: "{EmailAddress:" + email.toString() + "}",

                        success: function(response) {
                        alert(response.d);
//                            if (response.bolDNSFlag != "true") {
//                                alert("Plz try again");
//                                $("#txtemail").focus();
//                            }
                        },
                        error: function() {
                            alert("Error");
                        }
                    });
                    //Call the PageMethods
                    $.ajax(options);

                });


            });
        </script>

and server side is

[WebMethod]
    public static string DNSValidation(string EmailAddress)
    {
        Boolean bolDNSFlag = false;
        try
        {
            if (isEmail(EmailAddress.Trim()))
            {
                string[] host = (EmailAddress.Trim().Split('@'));
                string hostname = host[1];

                IPHostEntry IPhst = Dns.GetHostEntry(hostname);
                IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
                Socket s = new Socket(endPt.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                s.Connect(endPt);
                bolDNSFlag = true;
            }
        }
        catch (Exception exp)
        {
            bolDNSFlag = false;
        }
        return bolDNSFlag.ToString();
    }

Im not geting the breakpoint. Plz let me know if u have any idea.

Fist (in FireFox) press CTRL + SHIFT + J and load the Error console. Clear the contents before you reload the page. When you reload the page, if errors appear, fix them.

Is the call jquery ajax call being made? If you're using firefox, install the firebug extension. This extension will allow you to look at the ajax calls that are being made. It will make it easier for you to debug.

Also, jQuery offers a much simpler construct for ajax.

jQuery.post( 
	"TestingEmail.aspx/DNSValidation", 
	{"EmailAddress": email.toString()},
	function(data){
		alert(data);
	});

Also, I think you may be quoting the wrong parts in the data variable. Not sure on that, the error console will help you out there.

Change line 10 to:

data: "{EmailAddress: " + "'" + email + "'" +  " }",

/* Weird JavaScript :)

BTW: All of these shall work:

 data: '{"testData":"testing"}',
 data: "{testData: " + $('#<%= ddlCtrl.ClientID %>').val() + " }",
 data: "{testData: " + "'" + inputData.val() + "'" + " }",

~ Boris Momtchev
*/

Thanks for all your reply

Thanks for all your reply

So, just glancing at your sig, I wonder if you feel this thread is solved?

Best description with source code

Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.