calling $.post onBlur

I'm having trouble getting a $.post() to fire with an onblur(

Page 1 of 1

2 Replies - 10031 Views - Last Post: 24 September 2011 - 07:59 AM

#1 lkacenja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-February 09

calling $.post onBlur

Post icon  Posted 27 February 2009 - 04:26 PM

Hi,

I'm new to this forum and I'm trying it out as an alternative to jqueryhelp.com, which is pretty bad about responding and being helpful. So I appreciate any help I am given tremendously. I'm trying to fire a $.post jquery ajax function as a result of an onblur event. The whole script is inside some PHP which has been called by another $.post function. The onblur event fires just fine and the data requested is sent, but the PHP file (a second file for spellchecking) never receives the form data. I'm not exactly sure what the problem is. I can only foresee three possibilities. 1. there is some syntax error in the $.post, but I don't see one. 2. $.post can't fire in an onblur, which doesn't seem likely. 3. You cant fire a $.post within something that was loaded with a $.post. I really appreciate it. Thanks.

Here is the $.post summoned PHP that contains the jquery:
<?php 
$username = $_POST['username'];
// coming from the original $.post
echo'
<script type="text/javascript">
function spellcheck(mydata){
//alert(mydata); //successfully gives the value from the text input
$.post("/php/spellcheck.php", {objectname: mydata}, function (data){
alert(data);
		});
}

$(function() {
$(".warning").hide();
$("#name").blur(function(){
var mydata = $("#name").val();
spellcheck(mydata);
	});
});
</script>

<div class="top"></div>
<div id="createObjectContent">
<h2>Digitize A New Object</h2>
<div class="warning"></div>
<hr>
<form id="createObjectForm" action="php/processobject.php" enctype="multipart/form-data" method="POST">
<h2>Name It</h2>
<hr>
<input type="text" id="name" name="name"/>
<h2>Tag It</h2>
Comma separated semantic tags.
<hr>
<input type="text" id="tags" name="tags"/>
<h2>Upload Image</h2>
Image must be under 350k.
<hr>
<input type="hidden" name="MAX_FILE_SIZE"  value="100000" />
<input type="file" id="objectimage" name="file"
<input type="submit" name="submit" id="submit"/>
</form>
</div>
<div class="bottom"></div>
';
?>



Is This A Good Question/Topic? 0
  • +

Replies To: calling $.post onBlur

#2 joezim007  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 110
  • Joined: 13-September 08

Re: calling $.post onBlur

Posted 07 March 2009 - 01:04 PM

View Postlkacenja, on 27 Feb, 2009 - 04:26 PM, said:

Hi,

I'm new to this forum and I'm trying it out as an alternative to jqueryhelp.com, which is pretty bad about responding and being helpful. So I appreciate any help I am given tremendously. I'm trying to fire a $.post jquery ajax function as a result of an onblur event. The whole script is inside some PHP which has been called by another $.post function. The onblur event fires just fine and the data requested is sent, but the PHP file (a second file for spellchecking) never receives the form data. I'm not exactly sure what the problem is. I can only foresee three possibilities. 1. there is some syntax error in the $.post, but I don't see one. 2. $.post can't fire in an onblur, which doesn't seem likely. 3. You cant fire a $.post within something that was loaded with a $.post. I really appreciate it. Thanks.

Here is the $.post summoned PHP that contains the jquery:
<?php 
$username = $_POST['username'];
// coming from the original $.post
echo'
<script type="text/javascript">
function spellcheck(mydata){
//alert(mydata); //successfully gives the value from the text input
$.post("/php/spellcheck.php", {objectname: mydata}, function (data){
alert(data);
		});
}

$(function() {
$(".warning").hide();
$("#name").blur(function(){
var mydata = $("#name").val();
spellcheck(mydata);
	});
});
</script>

<div class="top"></div>
<div id="createObjectContent">
<h2>Digitize A New Object</h2>
<div class="warning"></div>
<hr>
<form id="createObjectForm" action="php/processobject.php" enctype="multipart/form-data" method="POST">
<h2>Name It</h2>
<hr>
<input type="text" id="name" name="name"/>
<h2>Tag It</h2>
Comma separated semantic tags.
<hr>
<input type="text" id="tags" name="tags"/>
<h2>Upload Image</h2>
Image must be under 350k.
<hr>
<input type="hidden" name="MAX_FILE_SIZE"  value="100000" />
<input type="file" id="objectimage" name="file"
<input type="submit" name="submit" id="submit"/>
</form>
</div>
<div class="bottom"></div>
';
?>



The only thing that seems like it could be wrong is the URL. Everything else looks fine and dandy to me. Try doing something in the PHP file that would leave a clue about whether or not it is being used, like write a log file on your server or something. If that works then there is something wrong with what your PHP document, otherwise it is more than likely the URL.
Was This Post Helpful? 0
  • +
  • -

#3 JohnPantooo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-September 11

Re: calling $.post onBlur

Posted 24 September 2011 - 07:59 AM

:withstupid: Re: blur method in JQuery
Hello Everyone,
In JQuery blur method trigger blur event when element will lose their focus. In this article I am using blur () method on html page. In html page I had created some text boxes, if any textboxes got focus then back color of textboxes will white and if textboxes lost their focus then textboxes back color will change......................... for more details please check out the following link.
http://mindstick.com...20blur%20method


:bananaman: :gunsmilie: Thanks a lot !!!!!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1