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 4615172
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:48:06+00:00 2026-05-22T01:48:06+00:00

I have this JS code: var recipesPost = function(name, ingredients, steps) { $.post(‘/api/recipes’, {

  • 0

I have this JS code:

var recipesPost = function(name, ingredients, steps) {
    $.post('/api/recipes',
        {
            name: name,
            ingredients: ingredients,
            steps: steps
        }
    ).done(function(data) {
        $("#result").append("RECIPES POST: OK!<br/>" + JSON.stringify(data) + "<br/>");
    }).error(function(error) {
        $("#result").prepend(JSON.stringify(error));
    });
};

Unfortunately, the HTTP request does not contain my data. It contains two empty variables (steps and ingredients) and name doesn’t appear anywhere. Here’s the raw request:

POST http://XXXXXXXXX.com/api/recipes HTTP/1.1
Host: XXXXXXXXX.com
Connection: keep-alive
Referer: http://XXXXXXXXX.com/
Content-Length: 19
Origin: http://XXXXXXXXX.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24
Content-Type: application/x-www-form-urlencoded
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

ingredients=&steps=

Any idea of what could be going on? The strange this is, if I replace the data I’m sending with string literals, then it gets sent correctly:

{
    name: "Foo",
    ingredients: "Bar",
    steps: "FooBar"
}

I’ve already checked with a JS debugger that name, ingredients and steps variables contain valid data when the call to recipesPost happens.

Update: Reigl suggested I try calling recipesPost("Foo", "Bar", "FooBar"). That worked.

I just debugged again, and although the type of my parameters is String (with my original code), they have a toJSON method. I am passing data from a form using JQuery, like $('#recipe_name').attr('value') (recipe_name being an HTML input). Is that an incorrect way of doing it?

Here’s the calling HTML

<form>
    Name: <input id="recipe_name" type="text" /><br/>
    Ingredients: <textarea id="recipe_ingredients"></textarea><br/>
    Steps: <textarea id="recipe_steps"></textarea><br/>
    <button type="button" onclick="recipesPost($('#recipe_name').attr('value'),$('#recipe_ingredients').text(),$('#recipe_steps').text())">Send</button>
</form>
  • 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-22T01:48:07+00:00Added an answer on May 22, 2026 at 1:48 am

    Edit: Per conversation with the op, the issue was with the JQuery version. Upgrading to 1.6.1 fixed the issue.

    Try quoting your key names:

        {
            'name': name,
            'ingredients': ingredients,
            'steps': steps
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code: var myObj = function () { this.complex =
I have this piece of code: $(#faq).click(function () { var url = $.get(faq, {
I have this code: var originalBorder = container.css("border"); container.hover(function(event) { event.stopPropagation(); $(this).css("border", "1px solid
I have this code var stats = { GetMetaData : function() { var url
Basic question; I have this code: var partipiansRow = '<div class=form-row ><input type=text id=name
I have this code: var Person = { name: , changes: { name to:
I have this Code: var items = jQuery('#main .imgteaser .txtwrap'); items.css(opacity,0.8); items.mouseenter(function(){ alert('enter'); jQuery(this).animate({
I have this portion of code: var hasAttribute = TypeDescriptor.GetAttributes(property.DeclaringType).OfType<CrmTypeAttribute>() .Any((attr) => ((CrmTypeAttribute)attr).Name ==
I have this code: var $msg = jQuery('<div></div>') .hide() .appendTo(document.body) ; if ($msg.is(:hidden)) {
Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]

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.