You're missing the dataType option that indicates how jQuery handles the response body and what it passes into the success callback. Usually jQuery is good at guessing the right thing, though...
What is the value of "data" in your callback? Also, did you do a network trace with fiddler to see your data being sent back from the server?
Can you confirm that the server is contacted and that it sends back a response on the network? If you've not used
fiddler, then you should install it -- it's very useful for debugging these sort of network issues.
vahid bakkhi
Member
342 Points
309 Posts
problem in return result Ajax
Mar 20, 2012 07:48 PM|LINK
hi
i use of this code for send param from a page to another page:
$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "http://localhost:56751/WebSiteSeconds/Default.aspx?p=2", success: function (data) { $("#result").html(data); }but when i use from it for send a param from a site to another site , i can send param but i can't recive the result
please help me how to return result from another site
thanks
BrockAllen
All-Star
28134 Points
4997 Posts
MVP
Re: problem in return result Ajax
Mar 20, 2012 07:57 PM|LINK
What type is the result? HTML? JSON? XML?
You're missing the dataType option that indicates how jQuery handles the response body and what it passes into the success callback. Usually jQuery is good at guessing the right thing, though...
What is the value of "data" in your callback? Also, did you do a network trace with fiddler to see your data being sent back from the server?
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
vahid bakkhi
Member
342 Points
309 Posts
Re: problem in return result Ajax
Mar 20, 2012 08:12 PM|LINK
thanks for your answer
i use from this code :
if (Request.QueryString["p"] != null) { Response.Write("ok"); return; }for me It does not matter to me the result be Html or xml or json
i want just a send param to second site ans do calculate and return the result with html or xml or json
please help me
BrockAllen
All-Star
28134 Points
4997 Posts
MVP
Re: problem in return result Ajax
Mar 20, 2012 08:14 PM|LINK
Can you confirm that the server is contacted and that it sends back a response on the network? If you've not used fiddler, then you should install it -- it's very useful for debugging these sort of network issues.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
vahid bakkhi
Member
342 Points
309 Posts
Re: problem in return result Ajax
Mar 20, 2012 08:29 PM|LINK
thanks for your answer
i in second site put breakpoint and i sure that param send to it ,but i don't know that return be result
please help me
thanks
protienshow
Member
716 Points
146 Posts
Re: problem in return result Ajax
Mar 20, 2012 08:57 PM|LINK
Can you post the action function you use to return the data?
It's either contentresult, actionresult or jsonresult.
In your case, you may want to use ContentResult in following behavior
Public ContentResult MyReturnData()
{
//process it
return Content("ok");
}
Create Dashboard In MVC
vahid bakkhi
Member
342 Points
309 Posts
Re: problem in return result Ajax
Mar 20, 2012 09:10 PM|LINK
thanks for your answer
if possible show me Complete code
protienshow
Member
716 Points
146 Posts
Re: problem in return result Ajax
Mar 20, 2012 09:14 PM|LINK
I need you to show us the complete c# code in the controller so that I can help you with that
Create Dashboard In MVC
vahid bakkhi
Member
342 Points
309 Posts
Re: problem in return result Ajax
Mar 20, 2012 09:20 PM|LINK
in site1 i use from this ocde :
<script type="text/javascript"> $(document).ready(function () { $('#id2').click(function () { $.ajax({ type: "Post", contentType: "application/json; charset=utf-8", url: "http://localhost:56751/WebSiteSeconds/Default.aspx?p=2", success: function (data) { $("#result").html(data); } }); }); </script>in site2 i use from this code :
if (Request.QueryString["p"] != null) { Response.Write("ok"); return; } else { Response.Write("Faild"); }BrockAllen
All-Star
28134 Points
4997 Posts
MVP
Re: problem in return result Ajax
Mar 20, 2012 09:24 PM|LINK
Sounds like maybe you're running into the same-origin policy.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/