So in default.aspx I have the code
<script type="text/javascript">
function validateForm()
{
test();
//here should return true or false and exit validateForm so not to run InsertUpdateData()
InsertUpdateData()
}
</script>
<script language="javascript" type="text/javascript">
(function test() {
var areaId = 98;
$.ajax({
type: "POST",
url: "GridViewData.aspx/GetRegions",
data: "{areaId:" + areaId + "}",
//data:99 ,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function artybones(data) {
// alert(data.d);
if (data.d == "Foo 98")
{ alert("its true"); }
else
{ alert("its false"); }
}
});
});
</script>
in GridViewData.aspx I have
<script runat="server">
[WebMethod]
public static string GetRegions(int areaId)
{
return "Foo " + areaId;
}
</script>
When I call test() from javascript i want it to return false but cant seem to geta value from test. Can someone post the code to do this? I know i am close..thanks in advance to those who post..