0

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.

5
Contributors
5
Replies
8
Views
8 Years
Discussion Span
Last Post by patelkisankumar
0

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.

-1

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
*/
0

Thanks for all your reply

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.