troubleshooting Question

asp.net 2.0 jquery if exists

Avatar of Seven price
Seven priceFlag for United States of America asked on
jQueryASP.NET
5 Comments1 Solution299 ViewsLast Modified:
Not checking correctly. It stops where the alert(Jsonstring) then it will not continue.

$(document).ready(function () { 
var JSONObject = new Object; //Initialize a new JSON object as this is the most common mistake making a JSON object 

$('#btn').click( 
function () { 

JSONObject.name = $('#lid').val().toString(); //Read Data from a textbox with id = lid 
JSONstring = JSON.stringify(JSONObject); //Stringyfy in JSON format 
alert(JSONstring); //Alert to check your request you can remove later on   /// Error it stops here does not post. but returns name
$( ".result" ).html( JSONstring )
$.ajax({ 
type: "POST", 
url: "test.aspx/checkExists", // Request Post to page Test1.aspx and calling method GreetingMessage 
data: JSONstring, // Pass Request String 
contentType: "application/json; charset=utf-8", 
dataType: "json", 
success: function (response) { 
//alert(response.d.toString() + " good"); 
$( ".result" ).html( response.d.toString() );
}, 
error: function (xhr, ajaxOptions, thrownError) { 
alert(xhr.status); 
alert(thrownError); 
$( ".result" ).html( response.d.toString() );
} 
}); 
} 
); 

}); //close ready


server side.
 public static string checkExists(string name) //Method should be declared as static 
        {
            return "your name exists " + name + Environment.NewLine + "this is your name";
        }  
ASKER CERTIFIED SOLUTION
Sammy

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros