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;
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
add a comment |
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
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
add a comment |
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
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
php jquery ajax
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
thank you it works
– hamza kamoune
Mar 26 at 13:12
add a comment |
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
thank you it works
– hamza kamoune
Mar 26 at 13:12
add a comment |
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
thank you it works
– hamza kamoune
Mar 26 at 13:12
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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