Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

Not getting the value passed by jquery ajax() in controller. Here is the code..

JavaScript
function OnClick(tablename) {
            var objtablename = tablename;
            alert(objtablename);
            $.ajax({
                url: '//localhost:1787/Table/Index/',
                type: "POST",
                data: objtablename,
                success: function (data) {
                    $('.result').html(data);
                    alert('Load was performed.');
                }
            });


i am getting "tablename" in alert but not in method (Index(string objtablename)).

Thanks in advance :)
Posted
Updated 10-May-12 23:49pm
v2
Comments
Ed Nutting 11-May-12 14:40pm    
How do you know your not? Have you checked the data being passed into the .ajax method? Or are you just relying on the data coming through in the request your receive? The issue may be that the data isn't being sent properly and not that the JavaScript object isn't passed in. Try debugging it in Developer Tools (in Chrome or Internet Explorer I recommend) to see if the JavaScript or request is the problem. Then update your question using the "Improve Question" link in green at the bottom right of your question.

Thanks and hope this helps,
Ed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900