How to use a jQuery data into a PHP code? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Is there an “exists” function for jQuery?How can I prevent SQL injection in PHP?How can I upload files asynchronously?How do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?Reference — What does this symbol mean in PHP?How do I return the response from an asynchronous call?“Thinking in AngularJS” if I have a jQuery background?

Putting Ant-Man on house arrest

Multiple fireplaces in an apartment building?

Raising a bilingual kid. When should we introduce the majority language?

My bank got bought out, am I now going to have to start filing tax returns in a different state?

Protagonist's race is hidden - should I reveal it?

How to keep bees out of canned beverages?

PIC mathematical operations weird problem

How long after the last departure shall the airport stay open for an emergency return?

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

Could moose/elk survive in the Amazon forest?

Align column where each cell has two decimals with siunitx

What do you call the part of a novel that is not dialog?

How do I check if a string is entirely made of the same substring?

Is accepting an invalid credit card number a security issue?

Can I criticise the more senior developers around me for not writing clean code?

Married in secret, can marital status in passport be changed at a later date?

Multiple options vs single option UI

Do you need a weapon for Thunderous Smite, and the other 'Smite' spells?

How would this chord from "Rocket Man" be analyzed?

With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space

All ASCII characters with a given bit count

How to translate "red flag" into Spanish?

Mistake in years of experience in resume?

What *exactly* is electrical current, voltage, and resistance?



How to use a jQuery data into a PHP code?



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Is there an “exists” function for jQuery?How can I prevent SQL injection in PHP?How can I upload files asynchronously?How do I check if an element is hidden in jQuery?Setting “checked” for a checkbox with jQuery?How do I redirect to another webpage?How to check whether a checkbox is checked in jQuery?Reference — What does this symbol mean in PHP?How do I return the response from an asynchronous call?“Thinking in AngularJS” if I have a jQuery background?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I want to use the value of limit and offset into my PHP code but I can't.



Here is my code:



var maxData = 0;
var limitt=6;
var offsett=1;

$.ajax(
url: "../model/conn.php",
type: 'POST',
data: 'getData='+'&limit='+limitt+'&offset='+offsett,
).done(function( data )
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;


);

<?php
if(isset($_POST['getData'])) {
$serv = "localhost";
$user = "root";
$psrd = "";
$db = "nonc";

$conn = mysqli_connect($serv, $user, $psrd, $db);

$limit=$_POST['&limit'];

$offs=$_POST['&offset'];

$sql = "SELECT * FROM non_confor limit $offs, $limit;";
$resltt = mysqli_query($conn, $sql);
$checkk = mysqli_num_rows($resltt);
?>


When I run my PHP page they show me that I have errors on $limt and $offs, because they don't receuve the data from AJAX.










share|improve this question
























  • are you trying to send a post call ?

    – Mohammed Yassine CHABLI
    Mar 22 at 16:04












  • the javascript and the Php code are in two separate files, are they?

    – Lelio Faieta
    Mar 22 at 17:35











  • yes they are in seperate files

    – hamza kamoune
    Mar 26 at 13:11

















0















I want to use the value of limit and offset into my PHP code but I can't.



Here is my code:



var maxData = 0;
var limitt=6;
var offsett=1;

$.ajax(
url: "../model/conn.php",
type: 'POST',
data: 'getData='+'&limit='+limitt+'&offset='+offsett,
).done(function( data )
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;


);

<?php
if(isset($_POST['getData'])) {
$serv = "localhost";
$user = "root";
$psrd = "";
$db = "nonc";

$conn = mysqli_connect($serv, $user, $psrd, $db);

$limit=$_POST['&limit'];

$offs=$_POST['&offset'];

$sql = "SELECT * FROM non_confor limit $offs, $limit;";
$resltt = mysqli_query($conn, $sql);
$checkk = mysqli_num_rows($resltt);
?>


When I run my PHP page they show me that I have errors on $limt and $offs, because they don't receuve the data from AJAX.










share|improve this question
























  • are you trying to send a post call ?

    – Mohammed Yassine CHABLI
    Mar 22 at 16:04












  • the javascript and the Php code are in two separate files, are they?

    – Lelio Faieta
    Mar 22 at 17:35











  • yes they are in seperate files

    – hamza kamoune
    Mar 26 at 13:11













0












0








0


1






I want to use the value of limit and offset into my PHP code but I can't.



Here is my code:



var maxData = 0;
var limitt=6;
var offsett=1;

$.ajax(
url: "../model/conn.php",
type: 'POST',
data: 'getData='+'&limit='+limitt+'&offset='+offsett,
).done(function( data )
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;


);

<?php
if(isset($_POST['getData'])) {
$serv = "localhost";
$user = "root";
$psrd = "";
$db = "nonc";

$conn = mysqli_connect($serv, $user, $psrd, $db);

$limit=$_POST['&limit'];

$offs=$_POST['&offset'];

$sql = "SELECT * FROM non_confor limit $offs, $limit;";
$resltt = mysqli_query($conn, $sql);
$checkk = mysqli_num_rows($resltt);
?>


When I run my PHP page they show me that I have errors on $limt and $offs, because they don't receuve the data from AJAX.










share|improve this question
















I want to use the value of limit and offset into my PHP code but I can't.



Here is my code:



var maxData = 0;
var limitt=6;
var offsett=1;

$.ajax(
url: "../model/conn.php",
type: 'POST',
data: 'getData='+'&limit='+limitt+'&offset='+offsett,
).done(function( data )
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;


);

<?php
if(isset($_POST['getData'])) {
$serv = "localhost";
$user = "root";
$psrd = "";
$db = "nonc";

$conn = mysqli_connect($serv, $user, $psrd, $db);

$limit=$_POST['&limit'];

$offs=$_POST['&offset'];

$sql = "SELECT * FROM non_confor limit $offs, $limit;";
$resltt = mysqli_query($conn, $sql);
$checkk = mysqli_num_rows($resltt);
?>


When I run my PHP page they show me that I have errors on $limt and $offs, because they don't receuve the data from AJAX.







php jquery ajax






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 15:43









double-beep

3,13641532




3,13641532










asked Mar 22 at 15:41









hamza kamounehamza kamoune

31




31












  • are you trying to send a post call ?

    – Mohammed Yassine CHABLI
    Mar 22 at 16:04












  • the javascript and the Php code are in two separate files, are they?

    – Lelio Faieta
    Mar 22 at 17:35











  • yes they are in seperate files

    – hamza kamoune
    Mar 26 at 13:11

















  • are you trying to send a post call ?

    – Mohammed Yassine CHABLI
    Mar 22 at 16:04












  • the javascript and the Php code are in two separate files, are they?

    – Lelio Faieta
    Mar 22 at 17:35











  • yes they are in seperate files

    – hamza kamoune
    Mar 26 at 13:11
















are you trying to send a post call ?

– Mohammed Yassine CHABLI
Mar 22 at 16:04






are you trying to send a post call ?

– Mohammed Yassine CHABLI
Mar 22 at 16:04














the javascript and the Php code are in two separate files, are they?

– Lelio Faieta
Mar 22 at 17:35





the javascript and the Php code are in two separate files, are they?

– Lelio Faieta
Mar 22 at 17:35













yes they are in seperate files

– hamza kamoune
Mar 26 at 13:11





yes they are in seperate files

– hamza kamoune
Mar 26 at 13:11












2 Answers
2






active

oldest

votes


















0














This is a syntax problem , here is the correction :



$.ajax(
type: 'POST',
url: '../model/conn.php',
data:
'getData':limit,
'offset':offsett
,
success: function(msg)
// rest of your code

);



Data attribute should have as value a json format







share|improve this answer

























  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12


















1














First thing, you are using POST method for form submission and passing data as a query string which is making an error. Correct that as below:



$.ajax(
url: "../model/conn.php",
type: 'POST',
data:
'getData': 1, // passing 1 as you are using getData in php.
'offset': offsett,
'limit': limitt
,
).done(function(data)
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;

);


After this, you need to make modification in your PHP code as below:



$limit=$_POST['limitt'];
$offs=$_POST['offsett'];


After this, your code should work fine. Hope it helps you.






share|improve this answer























  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12











  • Great, hope you will upvote and accept my answer :)

    – Rohit Mittal
    Mar 26 at 14:43











  • spot the difference ???

    – Mohammed Yassine CHABLI
    Mar 26 at 14:45











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303222%2fhow-to-use-a-jquery-data-into-a-php-code%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














This is a syntax problem , here is the correction :



$.ajax(
type: 'POST',
url: '../model/conn.php',
data:
'getData':limit,
'offset':offsett
,
success: function(msg)
// rest of your code

);



Data attribute should have as value a json format







share|improve this answer

























  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12















0














This is a syntax problem , here is the correction :



$.ajax(
type: 'POST',
url: '../model/conn.php',
data:
'getData':limit,
'offset':offsett
,
success: function(msg)
// rest of your code

);



Data attribute should have as value a json format







share|improve this answer

























  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12













0












0








0







This is a syntax problem , here is the correction :



$.ajax(
type: 'POST',
url: '../model/conn.php',
data:
'getData':limit,
'offset':offsett
,
success: function(msg)
// rest of your code

);



Data attribute should have as value a json format







share|improve this answer















This is a syntax problem , here is the correction :



$.ajax(
type: 'POST',
url: '../model/conn.php',
data:
'getData':limit,
'offset':offsett
,
success: function(msg)
// rest of your code

);



Data attribute should have as value a json format








share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 27 at 8:41

























answered Mar 22 at 16:09









Mohammed Yassine CHABLIMohammed Yassine CHABLI

1,4642529




1,4642529












  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12

















  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12
















thank you it works

– hamza kamoune
Mar 26 at 13:12





thank you it works

– hamza kamoune
Mar 26 at 13:12













1














First thing, you are using POST method for form submission and passing data as a query string which is making an error. Correct that as below:



$.ajax(
url: "../model/conn.php",
type: 'POST',
data:
'getData': 1, // passing 1 as you are using getData in php.
'offset': offsett,
'limit': limitt
,
).done(function(data)
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;

);


After this, you need to make modification in your PHP code as below:



$limit=$_POST['limitt'];
$offs=$_POST['offsett'];


After this, your code should work fine. Hope it helps you.






share|improve this answer























  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12











  • Great, hope you will upvote and accept my answer :)

    – Rohit Mittal
    Mar 26 at 14:43











  • spot the difference ???

    – Mohammed Yassine CHABLI
    Mar 26 at 14:45















1














First thing, you are using POST method for form submission and passing data as a query string which is making an error. Correct that as below:



$.ajax(
url: "../model/conn.php",
type: 'POST',
data:
'getData': 1, // passing 1 as you are using getData in php.
'offset': offsett,
'limit': limitt
,
).done(function(data)
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;

);


After this, you need to make modification in your PHP code as below:



$limit=$_POST['limitt'];
$offs=$_POST['offsett'];


After this, your code should work fine. Hope it helps you.






share|improve this answer























  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12











  • Great, hope you will upvote and accept my answer :)

    – Rohit Mittal
    Mar 26 at 14:43











  • spot the difference ???

    – Mohammed Yassine CHABLI
    Mar 26 at 14:45













1












1








1







First thing, you are using POST method for form submission and passing data as a query string which is making an error. Correct that as below:



$.ajax(
url: "../model/conn.php",
type: 'POST',
data:
'getData': 1, // passing 1 as you are using getData in php.
'offset': offsett,
'limit': limitt
,
).done(function(data)
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;

);


After this, you need to make modification in your PHP code as below:



$limit=$_POST['limitt'];
$offs=$_POST['offsett'];


After this, your code should work fine. Hope it helps you.






share|improve this answer













First thing, you are using POST method for form submission and passing data as a query string which is making an error. Correct that as below:



$.ajax(
url: "../model/conn.php",
type: 'POST',
data:
'getData': 1, // passing 1 as you are using getData in php.
'offset': offsett,
'limit': limitt
,
).done(function(data)
$("#d1 ").html(data);
while (limitt<maxData)
limitt= limitt+6;
offsett=offsett+6;

);


After this, you need to make modification in your PHP code as below:



$limit=$_POST['limitt'];
$offs=$_POST['offsett'];


After this, your code should work fine. Hope it helps you.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 22 at 17:21









Rohit MittalRohit Mittal

1,3551210




1,3551210












  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12











  • Great, hope you will upvote and accept my answer :)

    – Rohit Mittal
    Mar 26 at 14:43











  • spot the difference ???

    – Mohammed Yassine CHABLI
    Mar 26 at 14:45

















  • thank you it works

    – hamza kamoune
    Mar 26 at 13:12











  • Great, hope you will upvote and accept my answer :)

    – Rohit Mittal
    Mar 26 at 14:43











  • spot the difference ???

    – Mohammed Yassine CHABLI
    Mar 26 at 14:45
















thank you it works

– hamza kamoune
Mar 26 at 13:12





thank you it works

– hamza kamoune
Mar 26 at 13:12













Great, hope you will upvote and accept my answer :)

– Rohit Mittal
Mar 26 at 14:43





Great, hope you will upvote and accept my answer :)

– Rohit Mittal
Mar 26 at 14:43













spot the difference ???

– Mohammed Yassine CHABLI
Mar 26 at 14:45





spot the difference ???

– Mohammed Yassine CHABLI
Mar 26 at 14:45

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55303222%2fhow-to-use-a-jquery-data-into-a-php-code%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해