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

  • SEARCH
  • Home
  • 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 8229567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:50:21+00:00 2026-06-07T16:50:21+00:00

I am trying to send a json string and a variable thru ajax call

  • 0

I am trying to send a json string and a variable thru ajax call and edit the query in php file,
My code looks like

queryData = {
    "data": {
        "data_string": {
            "data": "oil",
            "default_field": "Content"
        }
    }
};
from = 0;
$.ajax({
    url: "/elasticsearch-head/lib/es/queryManipulate.php",
    type: 'POST',
    data: 'dataString',
    datatype: 'json',
    data: {
        field: queryData,
        start: this.from
    },
    success: function(data) {
        Dumper.alert(data);
    }
});

The PHP file looks like, Ive taken the two values in to variables, I wanna alter the json in php and return the value in the form {“from”: $from, “data”:{“data_string”:{“data”:”oil”,”default_field”:”Content”}}}

<?php
$testData=$_POST["field"];
$from=$_POST["start"];
?>

It should return the query 4 times and each time the value of $from should increment by 10
Is it possible to do that with ajax and php??

  • 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-06-07T16:50:22+00:00Added an answer on June 7, 2026 at 4:50 pm

    That would be my solution:

    function retreiveData(from)
    {
        queryData={"data":{"data_string":{"data":"oil","default_field":"Content"}}};
        $.ajax({
            url:"/elasticsearch-head/lib/es/queryManipulate.php",
            type: 'POST',
            data: 'dataString',
            datatype: 'json',
            data: {field : queryData, start : from},
            success:function(data)
            {
                Dumper.alert(data);
                if(from < (4-1)*10)
                {
                    retreiveData(from+10);
                }
            }
        });
    }
    retreiveData(0);
    

    This is a recursive function calling itself four times.

    EDIT: Or if I misread your question you could use a for-loop on the server side:

    <?php
    $testData=$_POST["field"];
    $from=$_POST["start"];
    for($i=0; ctype_digit($from) && is_numeric($from) && $i <  4; $i++)
    {
        $from+=10;
        //process data on the server side
        //echo $testData; // or whatever
    }
    ?>
    

    This would you let your data be processed four times.

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

Sidebar

Related Questions

I've been trying to send a JSON string to PHP server like this: $.ajax({
I'm trying to send to the client with django python a json string with
I am trying to send JSON data to a web server via the code
I am trying to send a json RPC ajax request when the page is
I am trying to send to my server a json file. The json format
am trying send an array to php file using $_POST ,still always getting an
I am trying to send a JSON string to the server and retrieve back
I'm trying to use the PHP json_encode function to encode some JSON to send
I am trying to send a large json string to a WCF Service created
I'm trying to write a jQuery function to send a query string to a

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.