Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 10:04

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



jquery post to php

Discussion on jquery post to php within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
FreewayC's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 60
Received Thanks: 4
jquery post to php

Hi,

ich möchte gerne den ausgewählten Index eines <select> Elementes über jquery mit "$.post" übermitteln. Der Wert wird richtig ermittelt, aber er wird nicht "richtig" gesendet.

jquery
Code:
$(document).ready(function(){
   $("#classSelect").click(function(){
      $.post("backend.php?action=loadClass",{classname : $("#alleKlassen option:selected" ).text()}); 
   });
});
php
PHP Code:
<?php
        
if(isset($_GET['action'])){
            switch(
$_GET['action']){
            case 
"loadClass":   $value $_POST['classname']; echo $value; break;              
            }
        }
        
?>

Exception:
Notice: Undefined index: classname



Quelle jquery

Code:
$.post( "test.php", { name: "John", time: "2pm" } );
Example: Request the test.php page and send some additional data along (while still ignoring the return results).


freundliche Grüße
FreewayC is offline  
Old 08/08/2014, 16:56   #2
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 705
Quote:
Originally Posted by FreewayC View Post
Hi,

ich möchte gerne den ausgewählten Index eines <select> Elementes über jquery mit "$.post" übermitteln. Der Wert wird richtig ermittelt, aber er wird nicht "richtig" gesendet.

jquery
Code:
$(document).ready(function(){
   $("#classSelect").click(function(){
      $.post("backend.php?action=loadClass",{classname : $("#alleKlassen option:selected" ).text()}); 
   });
});
php
PHP Code:
<?php
        
if(isset($_GET['action'])){
            switch(
$_GET['action']){
            case 
"loadClass":   $value $_POST['classname']; echo $value; break;              
            }
        }
        
?>

Exception:
Notice: Undefined index: classname



Quelle jquery

Code:
$.post( "test.php", { name: "John", time: "2pm" } );
Example: Request the test.php page and send some additional data along (while still ignoring the return results).


freundliche Grüße
I recommend using $.ajax instead:

Code:
$("#classSelect").click(function(){
	$.ajax({
		type: "POST",
		data: $("form#form").serialize(),
		url: "test.php",
		success: function(data){
			// data is the value returned from test.php
		}
	});
	return false;
});
turk55 is offline  
Reply


Similar Threads Similar Threads
[jQuery] Simple jQuery-Plugin Template
01/21/2014 - Coding Snippets - 0 Replies
Ohne Parameter: Der Code selbst: (function( $ ) { $.fn.popupContent = function() { //Funtions-Block alert($( this ).text()); }; }( jQuery ));



All times are GMT +1. The time now is 10:05.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.