Click here to Skip to main content
15,886,755 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello experts,

Can you please give me a gist on how to achieve below?

I have page1.aspx where in there is an Iframe that runs callback.html

In callback.html I have a string "TESTPASSED"

This string should be passed to Page2.aspx

Page1.aspx-->callback.html-->
Execute javascript Test() function and Pass string value --> Page2.aspx

Your help is much appreciated.

What I have tried:

Function Test(){
var jsonInput ="TESTPASSED";
    $.ajax(
                            { 
                                type: "POST",
                                dataType: "text json",
                               url: "Page2.aspx ",
    	                      data:"{mystring:"+jsonInput+"}",
                                contentType: 'application/json'
    });
	
}



And my Page2.aspx code behind is as below 

Public Class RequestResponse
    Public temp As String
End Class

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim resp As RequestResponse = New RequestResponse
Dim result as string = Request.Form("mystring")
//Not sure how to get the string value here TESTPASSED

End Sub
Posted
Updated 21-Apr-17 6:21am
v3
Comments
F-ES Sitecore 21-Apr-17 7:06am    
"data" needs to be something like

data:"{mystring:'TESTPASSED'}"

in your aspx code you'd then use Request.Form["mystring"]
sudevsu 21-Apr-17 9:53am    
I did try that way too but no luck. result is always showing nothing in server side while debugging.
F-ES Sitecore 21-Apr-17 10:11am    
Either the ajax code isn't being called, or the call is attempted but there is something wrong with it

https://forums.asp.net/t/1982579.aspx?Using+the+browser+s+dev+tools+to+diagnose+ajax+problems+and+other+things+
sudevsu 21-Apr-17 10:45am    
Oh No Ajax is being called. Because control is going to my server side and I have my ajax in try catch block so I am sure it is called but request.Form("mystring") is always nothing. Can't figure it out why?
F-ES Sitecore 21-Apr-17 10:57am    
Look at the link I posted and use the browser tools to see what data you are sending to the method.

1 solution

This did the trick to me. thanks again F-ES Sitecore

$.ajax(
                             {
                                 type: "POST",
                                                                 data: 'mystring=' + myInput ,
                                                                url: "Page2.aspx",
                                 success: function (result) {
                                     debugger;
                                     alert("success :" + JSON.stringify(myInput));
                                 },
                                 error: function (xhr, status) {
                                     debugger;
                                     alert("fail " + status);
                                 }
                             });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900