开发者

Jquery .post question - into a string to be posted again

Using $.post I am sending a some logon information to a server. This returns a html page which I am them limiting down by class called .loggedIn

I then want to resend this information away using $.post to a server. I'm do this using phonegap on an Iphone app so I don't have to worry about cross-domain issues.

My issue is the data from the first post doesnt seem to post to the second site .. All I get returned from my second script is undefined=undefined.

Here is my code -

$(document).ready(function() {
    $.post("https://www.somesite.com /dyns/dologin?action=login&origin=homepage", { login_ffNumber: "1111111", login_surname: "name" , login_pin: "1111"},
    function(data) { 
    $('.result')开发者_如何学Go.html($('.loggedIn',data));
    stuff = $('.loggedIn',data)
    //alert(datatostring);
    //alert(stuff);
    sendtoserver(stuff);
    });

    function sendtoserver(stuff) {
        $.post("http://31dayswithjustin.com/qf/1.1/qfgraber.asp?", stuff, function(data) {$('.server').html(data);} );
    }

})


Asuming your stuff variable gets the value you expect, your mistake is sending it "as is" (a jquery object) and not sending its content as a named parameter. The easiest way to send it properly would be the following:

function sendtoserver(stuff) {
    $.post("your_url", {"stuff": stuff.html()}, function...} );
}

(Asuming you want to send the stuff innerHTML) But, you have to recieve the stuff parameter explicitly on the server:

   qfgrabber.asp:    
   <% 
       Dim stuff as String
       stuff = Request.Form("stuff")
       ...
       '(continue with your page using the 'stuff' variable when needed)
    %>

(I wrote this in classic ASP cause your server filename ends in .asp)

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜