Solved

a problem in sending the form varaibles using jquery .post()

Posted on 2011-09-28
7
215 Views
Last Modified: 2012-05-12
Hi all, Im trying to sumbit a Form using Jquery using .post()
the problem is that not all the forms field are generating (when using serialize)

(when im checking the results using the alert its showing:flag=on&id=12024&email=1andonly%40gmail.com) so only the 3 input field are generating)


$("#"+popup_form_id).submit(function(e) {
                         //   alert("Hello world!");
							//fElement.attr('flag','1');
							e.preventDefault();
						//"mark" the input name =flag as spam 
						    $(":hidden[name='flag']","#"+popup_form_id).val("on");
							fElement.toggle();
							//$.ajax(
							alert($(this).serialize());
							$.post(url,$(this).serialize());
								
							
					})

Open in new window

<form id = "popup_form_{$row['id']}"  action ="" method ="post" style="background-color:white; border:2px solid blue;padding:4px; width:250px; display :none; position:absolute"  onsubmit = "return false;">

			<input type ="hidden" name="flag" value = "no" >

			<input type="hidden" name="id" value ="{$row['id']}">

			<input type="hidden" name ="email" value ="{$row['email_address']}">

			<input type="submit" name="spamIt" value="SpamIt"  style="margin-right:15px;">

			<input type="button" value="Close" onclick="closePopup()"/>

			

			</form>

    </tr>

Open in new window

0
Comment
Question by:Nura111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
MacAnthony earned 500 total points
ID: 36719437
From the serialize documentation:

No submit button value is serialized since the form was not submitted using a button. For a form element's value to be included in the serialized string, the element must have a name attribute.

So the submit button won't be serialized since it's not submitting via that, and the input button doesn't since it does not contain a 'name' attribute.
0
 

Author Comment

by:Nura111
ID: 36719515
ok in the page im sending the request is the following code so what can Is end to .post in order for it to work? or thats is not how Im suppose to do that?

if (isset($_POST['spamIt']))
if (isset($_POST['spamIt'])){
		//echo "try";
		 $id = $_POST['id'];
		 $email = $_POST['email'];

		 $sql= BaseModel::getSqlObject();
		
		 $query = "SELECT * FROM BlackList WHERE email_address = '$email'";	
	     
		if (($result=$sql->Query($query)) === FALSE)
           die(ShowError("Server Query Error"));
		$num = $result->num_rows;
	   
	//check if email is not already exist in BlackList
	    if ($result->num_rows == 0){
   			 $insert_query = "INSERT INTO BlackList(email_address) VALUES ('$email')";
			 
			 if (($result=$sql->Query($insert_query)) === FALSE)
           	die(ShowError("Server Insert Query Error"));
		}
		
		$insert_query =	"UPDATE ServiceRequests SET spam = 1 WHERE id = '$id'";
		if (($result=$sql->Query($insert_query)) === FALSE)
           	die(ShowError("Server Insert Query Error service"));


			die ("ok");
         
	
		
 
		
		}

Open in new window

0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36719614
You could make another hidden field with the name and value of spamIt in the form and that one should submit. The other option would be to change the current field from a submit button to a type "button" and have an onclick event of onclick="this.form.submit();".

I haven't tested either of those, but I think they should both work.
0
CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

 

Author Comment

by:Nura111
ID: 36719683
ok Im getting form the post request the following error 500 Internal Server Error
            107ms

any idea whats is happening?
0
 
LVL 11

Expert Comment

by:MacAnthony
ID: 36720088
I'm not sure what would be causing the 500 error, but it shouldn't be the call itself from what you've provided.
0
 

Author Comment

by:Nura111
ID: 36720093
I also attched the code in the php script its not long can you take a look? I cant figure it out
0
 

Author Comment

by:Nura111
ID: 36720224
Can it be a Permission issue?
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question