question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ajaxURL behavior.

See original GitHub issue

Hi, I’ve been working a lot with tabulator these days… and I have been using this method to retrieve data to my table without problems.

Code Behind.


[WebMethod(CacheDuration = 0)]
        public static string GetRoomList()
        {
            string result;
            using (var ctx = new ServiceContext())
            {
                var roomList = (from c in ctx.Rooms
                                select c);
               
               result =  JsonConvert.SerializeObject(roomList);
            }
            return result;
        }

Javascript

function createRoomData() {
        $("#gridRoom").tabulator({
            height: "400px",
            fitColumns: true,
            columns: [
                { field: "roomID", visible: false },
                { title: "Code", field: "roomCode", sorter: "string" },
                { title: "Description", field: "roomDescription" },
                { title: "Habited", field: "roomHabited", align: "center" },
            ],
        });
    }

function loadRoomData2() {
        $.ajax({
            url: "room.aspx/GetRoomList",
            type: "POST",
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            beforeSend: function () {
                // $(".l-preloader").show();
                //spinner.spin(spinnerTarget);
            },
            success: function (data) {
                var json = data.d;
                $("#gridRoom").tabulator("clear")
                                        .tabulator("setData", json);
                //spinner.stop();
            },
            error: function (xhr, textStatus, errorThrown) {
                manageError(xhr, textStatus, errorThrown);
                //spinner.stop();
            },
        });
    }

    createRoomData();
    loadRoomData2()

This implementation for Visual Studio C# code works fine. Now, I tried to use a different approach… use the ajaxURL option to fill my table, like This.

Javascript

    function loadRoomData() {
        $("#gridRoom").tabulator("setData", "room.aspx/GetRoomList", {}, "POST");
    }

That implementation throws this error:

image

Now, I’ve seen that for ajax request to work in Visual Studio I need to specify options

 type: "POST",
 contentType: 'application/json; charset=utf-8',
 dataType: 'json'

So I don’t know if I can set this options using the ajaxURL or the Params in the setData function.

Could you clarify me if I’m doing something wrong?

Thanks!!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lac616commented, Apr 13, 2017

No issues here, works beautifully!

0reactions
cemmonscommented, May 10, 2017

Hi, it’s me again, thanks a lot for the new feature, now I’m implementing it and my response using a web method is something like this.

{"d":"
	[
	{\"surCode\":\"01\",\"intCode\":\"rpm011700002\",\"cusCode\":\"0001958259\",\"rotCode\":\"rpm01\",\"sicValid\":true},
	{\"surCode\":\"01\",\"intCode\":\"rpm011700004\",\"cusCode\":\"0001462551\",\"rotCode\":\"rpm01\",\"sicValid\":true}
	]"

I can’t remove that d from the response, because it is a security fix implemente by .net3.5 so I was hoping you’d now any way to get inside that d… from tabulator, using the setData function.

Right now my grid doesn’t show any data. but it is returned correctly

Read more comments on GitHub >

github_iconTop Results From Across the Web

The correct method to pass query vars in AJAX using ajaxurl
I'm trying to override the default behavior with ajax. The problem here is not actually a problem, but a wish more. I have...
Read more >
jQuery.ajax() | jQuery API Documentation
jQuery.ajax( url [, settings ] )Returns: jqXHR. Description: Perform an asynchronous HTTP (Ajax) request. version added: 1.5jQuery.ajax( ...
Read more >
Jquery Ajax url path Issue - Stack Overflow
i have the ajax function in test.php. load.php is just simply echoing "wow". $("#test").click(function(){ ...
Read more >
AJAX URL Selection Parameters - QlikView App Dev
AJAX URL Selection Parameters - Select Literals ... We need the behavior of this url to only select the singlevalue 'Sales'.
Read more >
AJAX update and file download in one blow
getModelObject()); } }; item.add(download); item.add(new AjaxLink<Void>("link") { @Override public ... AjaxRequestTarget; import org.apache.wicket.behavior.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found