Please help me with the following situation:
there is the page p1.aspx with only one button:
<button id="btn1" onclick="btnclick();">Button</button>
<script type="text/javascript">
$('#btn1').click(function () {
$.getJSON("http://localhost/p2.aspx", function (data) {
$.each(data, function (i, field) {
alert(field);
});
});
});
</script>
Above is how I want to get the JSON text via javascript.
Web application http://localhost/p2.aspx
is redirected to http://localhost/p3.aspx
inside. And the page http://localhost/p3.aspx
again is redirected back to
http://localhost/p2.aspx?code=1
.
code=1
is the value I want read in my javascript code. But it's not works.
In p2.aspx I generate JSON data as following
Response.Clear();
Response.ContentType = "application/json; charset=utf-8";
Response.Write(jsonString);
Response.End();
After this I can not read json data via javascript. But if I just put the http://localhost/p2.aspx
via web browser then it get json data on the page.