Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7568493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:56:24+00:00 2026-05-30T14:56:24+00:00

var addRecord, getRecords, wcfServiceUrl; // Use strict for all other functions // Based on

  • 0
var addRecord, getRecords, wcfServiceUrl;

// Use strict for all other functions
// Based on post at:
// http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/

(function () {
    "use strict";

    wcfServiceUrl = "http://localhost/WcfRestUpdates/eval/evals";

    // Execute when the DOM is fully loaded
    $(document).ready(function () {
        getRecords();
    });

     // Add record
    $(function () {
        $("#butCallAjax").click(addRecord);                

    });     

    //Add record function start
    addRecord = function () {
        //jQuery.support.cors = true;
        $.ajax({
                    type: "POST",
                    url: wcfServiceUrl,                    
                    //data: '<Eval xmlns="http://schemas.datacontract.org/2004/07/WcfRestUpdates"><Comments>' + document.getElementById("txtComment").value + '</Comments><Submitter>' + document.getElementById("txtSubmitter").value + '</Submitter></Eval>',
                    data: '<Eval xmlns="http://schemas.datacontract.org/2004/07/WcfRestUpdates"><Comments>' + document.getElementById("txtComment").value.toString() + '</Comments><Submitter>' + document.getElementById("txtSubmitter").value.toString() + '</Submitter></Eval>',
                    //data: jQuery.parseJSON('{"Comments":"This is test comment","Id":"1","Submitter":"Mayank","Timesent":"\/Date(928129800000+0530)\/"}'),
                    //ContentType:"application/json; charset=utf-8",
                    //dataType: "json",   
                    contentType: "application/xml",                   
                    dataType: "xml",   
                    success: getRecords,
                    error: function (xhr) {
                        if(xhr.status = 200) {
                            getRecords;
                        }
                        else{
                            alert("Error in POST:" + xhr.status.toString() + "and "+ xhr.responseText);                        
                            //var obj = jQuery.parseJSON('{"Comments":"This is test comment","Id":"1","Submitter":"Mayank","Timesent":"\/Date(928129800000+0530)\/"}');
                            //alert("Error in POST:");  
                            //alert("Error in POST:" + obj.Id);                        
                        }
                    }
                });        
    };

    //Add record function end

    //Get records function start
    getRecords = function() {
        jQuery.support.cors = true;
        $.ajax({
            type: "GET",
            url: wcfServiceUrl,
            data: "{}",            
            ContentType:"application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {

                //alert('success');
                //var resultText = "<div>";
                var divR = document.getElementById("divResult");
                //[{ "Comments": "this is my first comment", "Id": "1", "Submitter": "Mayank", "Timesent": "\/Date(1329473557750+0530)\/" }, { "Comments": "this is my first comment", "Id": "2", "Submitter": "Mayank", "Timesent": "\/Date(1329473813781+0530)\/"}]
                divR.innerHTML = '<div style="clear:both;width:7%;float:left;padding:5px;" class="sb">' + 'Id' + '</div>';
                divR.innerHTML += '<div style="width:15%;float:left;padding:5px;" class="sb">' + 'Submitter' + '</div>';
                divR.innerHTML += '<div style="width:40%;float:left;padding:5px;" class="sb">' + 'Comments' + '</div>';
                divR.innerHTML += '<div style="width:20%;float:left;padding:5px;" class="sb">' + 'Date/Time' + '</div>';
                $.each(data, function (i, theItem) {

                    //var option = document.createElement("option");
                    //option.text = theItem.toString();
                    //option.value = theItem.toString();

                    try {
                        //alert('success add combo');
                        //combo.add(option, null); // Other browsers
                        var datetime = new Date(theItem.Timesent.match(/\d+/)[0] * 1);
                        divR.innerHTML += '<div style="clear:both;width:7%;float:left;padding:5px;" >' + theItem.Id.toString() + '</div>';
                        divR.innerHTML += '<div style="width:15%;float:left;padding:5px;" >' + theItem.Submitter.toString() + '</div>';
                        divR.innerHTML += '<div style="width:50%;float:left;padding:5px;" >' + theItem.Comments.toString() + '</div>';
                        divR.innerHTML += '<div style="width:20%;float:left;padding:5px;" >' + datetime.toDateString() + '</div>';
                    }
                    catch (error) {
                        alert('error found');
                        combo.add(option); // really old browser
                    }

                });
            },
            error: function (xhr) {
                        alert("Error in GET:" + xhr.responseText);
            }               
        });
    };
    //Get records function end
}) ();

I need to display result to div once POST submitted successfully. It works fine with FireFox. but with Safari, I need to refresh the browser to GET the POSTED data. “getRecords” function used to display data in div. which works fine in all browsers on page load. but it is not working as a part of ajax POST > successful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:56:26+00:00Added an answer on May 30, 2026 at 2:56 pm
    $.ajax({
                    type: "POST",
                    url: wcfServiceUrl,
                    //data: '<Eval xmlns="http://schemas.datacontract.org/2004/07/WcfRestUpdates"><Comments>' + document.getElementById("txtComment").value + '</Comments><Submitter>' + document.getElementById("txtSubmitter").value + '</Submitter></Eval>',
                    data: '<Eval xmlns="http://schemas.datacontract.org/2004/07/WcfRestUpdates"><Comments>' + document.getElementById("comment").value + '</Comments><Submitter>' + document.getElementById("submitter").value + '</Submitter></Eval>',
                    contentType: "text/xml",
                    dataType: "xml",
                    success: function (xhr) { getRecords(); },
                    error: function (xhr) {
                                if(xhr.status = 200) {                            
                                    getRecords();
                                }
                                else{
                                    alert("Error while adding record with error-code:" + xhr.status.toString() + "and "+ xhr.responseText);                                                   
                                }
                            }
    
                });
    

    Improper calling of function “getRecord” in ajax “POST” success. Used “function (xhr) { getRecords(); }” instead of “getRecord” and it works!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var theNewWindow = window.open('http://www.example.com', 'example', ''); How can I use the document object of
var query1 = urlencode($('input[name=searchTerm]').val()); //user1 $.getJSON('http://twitter.com/friends/ids.json?screen_name='+ query1 +'&jsoncallback=?', function(data){ $('content').append(''+data.length+''); }); This is a
var valueAsText = $('#counts span').text(); I use this tiny script to parse a span
var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = 'http://www.mydomain.com/bleh.php'; script.id =
var jqxhr = $.post(/cms/menu_pagesave, { page_id: pageID, name : value_td, url : value_url },
var i : integer; i := 1234567; Given the above, I want the string
var y = new w(); var x = y.z; y.z= function() { doOneThing(); x();
var insInvoice = new NpgsqlCommand( @INSERT INTO invoice_detail( invoice_id, invoice_detail_id, product_id, qty, price, amount)
var foo = { someKey: someValue }; var bar = someKey; How do I
var newUser = new tblUser() { Email = strEmail, Password = strPassword, DateBirth =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.