|
![](/images/resource/spacer.gif) |
|
สร้าง json object แล้ว post ไปที่อีกไฟล์ ไฟล์ฝั่งรับ json จะรับค่าอย่างไรครับ Web (ASP.NET), C# |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
สร้าง json object ได้แล้ว จะส่ง json ที่สร้างขึ้นไปที่อีกไฟล์ด้วยวิธี post
อยากทราบว่าไฟล์ฝั่งรับค่า json (setPrice.aspx) จะรับค่าได้อย่างไรครับ งง
เพราะไม่ได้รับค่าจาก queryString หรือ form
Code (JavaScript)
function send(json) {
$.ajax({
url: 'setPrice.aspx',
type: 'post',
data: JSON.stringify(json),
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
$('#result').html('success');
},
error: function(data){
$('#result').html('fail');
}
});
}
ขอบคุณครับ
Tag : .NET, Ajax, jQuery, Web (ASP.NET), C#
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-04-04 21:35:04 |
By :
Aod47 |
View :
2621 |
Reply :
2 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ฝั่งส่ง Post
Code (JavaScript)
function send(json) {
$.ajax({
url: 'setPrice.aspx/TestMethod', //มันจะวิ่งไปไฟลนี้ setPrice.aspx แล้วเข้าหา Method นี้ TestMethod
type: 'post',
data: JSON.stringify(json),
contentType: "application/json; charset=utf-8",
traditional: true,
success: function (data) {
$('#result').html('success');
},
error: function(data){
$('#result').html('fail');
}
});
}
ฝั่งรับ setPrice.aspx
Code (C#)
[HttpPost]
public string TestMethod(Person person)
{
return person.Name; // response value
}
![](/images/bbcode/grin.gif?v=1001) ![](/images/bbcode/grin.gif?v=1001)
|
ประวัติการแก้ไข 2015-04-06 09:02:47 2015-04-06 09:03:36
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-04-06 09:01:22 |
By :
ipstarone |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
กระจ่างเลยครับ ขอขอบคุณที่ช่วยสอนให้ครับผม เป็นความรู้ใหม่สำหรับผมเลยทีเดียว
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-04-06 09:12:23 |
By :
Aod47 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 04
|