The following JQuery Request works fine in IE but not in FF and Chrome.
I am running the following page from its file location e.g. file:///C:/Test/json.htm and requesting a page running on localhost.
What is the reason for this?
And how can I get it to work for FF and Chrome?
<body>
<input type="button" value="Search" id="search-button" />
<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function() {
$('#search-button').click(function() {
var parms = {
id: 27
};
$.ajax({
type: 'POST',
url: 'http://localhost:51621/Test/GetJSONMessage/',
async: false,
data: parms,
dataType: 'json',
success: function(data, testStatus) {
alert(data.message);
}
});
});
});
</script>
</body>
Where GetJSONMessage is supplied by an ASP.Net MVC JSonResult :
[HttpPost]
public JsonResult GetJSONMessage(int id)
{
return Json(new { message = ("hello world " + id.ToString()) });
}