CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Threaded View

  1. #11
    Join Date
    May 2012
    Posts
    8

    Re: xmlHttpRequest.Send() issues.

    Code:
    function getResponse() {
    
    
    
            var currentDate = new Date();
            var sendMessage = JSON.stringify({
                SendTimestamp: currentDate,
                Message: "Message 1"
            });
    
    $.ajax({
                type: "POST",
                url: "http://L45723:1802/?callback=testcallback",
                data: sendMessage,
                contentType: "application/json",
                beforeSend: function(xhr) {
                     xhr.setRequestHeader("Authentication", "Basic " + $.encodeBase64("server:server123")); //May need to use "Authorization" instead
                },
                success: function(data){
                    $('#_receivedMsgLabel').append(data.Message + '<br/>');
                    getResponse();
                }
            });
    
        }
    Changed my code to as above...as in the link, but don't think I understood it because I got this in Firefox:

    $.encodeBase64 is not a function
    beforeSend(xhr=Object { readyState=0, setRequestHeader=function(), getAllResponseHeaders=function(), more...})ShowComet9.aspx (line 39)
    ajax(url=undefined, options=Object { type="POST", url="http://L45723:1802/?callback=testcallback", data="{"SendTimestamp":"2012-...,"Message":"Message 1"}", more...})jquery-1.7.1.js (line 7547)
    getResponse()ShowComet9.aspx (line 41)
    ()ShowComet9.aspx (line 56)
    [Break On This Error]

    ...thentication", "Basic " + $.encodeBase64("server:server123")); //May need to use...

    Where do I get the encodeBase64 jQuery function from?
    Last edited by PeejAvery; May 31st, 2012 at 04:32 PM. Reason: Added code tags

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
  •  





Click Here to Expand Forum to Full Width

Featured