www.webdeveloper.com
Results 1 to 4 of 4

Thread: Send Javascript Eval() string to classic ASP page via POST

  1. #1
    Join Date
    Dec 2006
    Posts
    115

    Send Javascript Eval() string to classic ASP page via POST

    I have a javascript array created through an eval() that I want to send to a classic asp page, I believe through a .Post() (but am happy to go whatever route is best). I am not aware on how to do this at all and all of my attempts have been futile. If anyone can help me with the below code, it would be greatly appreciated. This is the javascript variable setup:

    Code:
    var tempOrders = eval('(' + '[{AccountOverride: {Id:"-9223372036854775808", Name:"", Number:"", HHID:"-9223372036854775808", HHName:"", Registration:"", RepId:"", Source:"", ' +
                            'Status:"0", IsDeliveryVsPayment:"False", IsEmployee:"False", IsManaged:"False", IsOnMargin:"False", OptionStatus:"", OptionAgreement:""}, ' +
                            'Id:"-9223372036854775808", ' +
                            'Action:"", ' +
                            'Type:"0", ' +
                            'ProductOverride: {Symbol:"", AssetClass:"", Cusip:"", HasShortTermRedemptionFee:"False", HasTicker:"False", Id:"-9223372036854775808", Name:"", Type:"None", AssetType:"", AssetSubtype:""}, ' +
                            'QuantityType:"", ' +
                            'Quantity:"", ' +
                            'PriceType:"", ' +
                            'PriceTypeAmount:"0", ' +
                            'ExchangeSymbol:"", ' +
                            'Condition:"", ' +
                            'AcceptingRepId:"", ' +
                            'DateReceived:"", ' +
                            'TimeReceived:"", ' +
                            'CommissionCharge:"", ' +
                            'CommissionAmount:"0", ' +
                            'ConfirmNote:"", ' +
                            'DivCapGain:"", ' +
                            'Breakpoint:"0", ' +
                            'BuyPrice:"", ' +
                            'SellWaiver:"", ' +
                            'PositionType:"", ' +
                            'SpecialCondition:"", ' +
                            'TimeInForce:"", ' +
                            'WaiveFee:"False", ' +
                            'RolloverCusip:"", ' +
                            'RemoveTrade:"False", ' +
                            'Index:"", ' +
                            'TimePriceDiscretionaryOverride:"False"}]' + ')');
    Values end up being placed in this in some backend JQuery, and after that is set, a function is called, where I want to then send this information back to a different classic .asp page to be displayed to the user.

    Code:
    function SendOrdersToParent() {
        if (tempOrders[0]['ProductOverride']['Id'] == '-9223372036854775808') {
            if (!ValidateInitialFields()) return false;
        }
    
        if (window.opener && (typeof window.opener.OrderCreated != 'undefined')) {
            // adding this logic to disable multiple orders being created.
            if (!creatingOrder) {
                creatingOrder = true;
                window.opener.OrderCreated(tempOrders);
            }
        }
    
        //for(var i = 0; i < tempOrders.length; i++){
        //  tempOrders[i]['AccountOverride']['Number'] = "123456";
        //  tempOrders[i]['QuantityType'] = "D";
        //  $("#arrayTemp").append(tempOrders[i]['Quantity'] + ' : ' + tempOrders[i]['AccountOverride']['Number'] + '<br/>');
        //}
        var obj = JSON.parse(tempOrders);
        $.ajax({
            type: "POST",
            traditional: true,
            url: "Overview.asp",
            data: JSON.stringify(obj),
            cache: false,
            success: function(){            
                    $("#arrayTemp").append("Successful Post");
                },
            error: function(){
                alert("Unsuccessful post");
            }
        });
        //window.close();
        return false;
        }
    The overview.asp page will handle it and just display the data on the screen, i'll do some styling to it and everything, but basically overview.asp would have something like this on it;

    Code:
    <%
    dim arrayVals
    arrayVals = request.form("tempOrders")
    if arrayVals <> "" then
    response.write "returned : " & tempOrders
    end if
    %>
    Any suggestions would help me a great deal and be appreciated. Thanks in advance, NickG

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,273
    You will probably solve your question with JSON and ASP, search for this words...

  3. #3
    Join Date
    Dec 2006
    Posts
    115
    I've done that pretty extensively through google, this forum and stackoverflow.com and have not had any luck. Nobody seems to be able to give me any help on code, just on generic search terms, I assure you i've pretty much exhausted my generic searching and feel like I haven't made any progress, has nobody ever used the .POST() method to send an eval() string in classic asp. I agree it's outdated, and if I had a choice I would not be using this method, but sadly I don't.

  4. #4
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,273
    Your eval seems wrong. It build a javascript object, useless for a POST !

    Send simply the original string (or a JSON.stringify(tempOrders) to test with an alert(JSON.stringify(tempOrders)). Then work with ASP ...
    Last edited by 007Julien; 08-01-2013 at 02:36 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles