ajax - Get value in field before submit
I want to got to page with AJAX and get the value that is in the field because i want to get the value and add my value also.
this is what i have so far:
var i = $(msg).find('[name*=user]').attr('value');
What exactly do you want? You already got the value there in your beforeSend. You want to add your own value? Just do it then.
If you want me to help, you have to be a bit more specific about what exactly is causing you trouble.
On a side note: The parameter msg has to hold the selector string for your container DOM element. Why on earth would you call that "msg"?
Also, do you have any good reason to use synchronous AJAX?
Oh, interesting. Just when I wrote "synchronous AJAX" I threw up a little.
Well there is a page which is file.php.
There is a field named user. The field has a value which is the username.
I want to get that value and add my value to the end, but if there is no value I just want to post my own.
Ok, that's not all that hard.
Within the beforeSend, you can try something like this:
I really don't know because i am new to the jquery scene, I was just trying to get with trial an error.
I also don't know why i used synchronous, I guess i'll switch it.
It gave me an error in firebug. "Field is underdefiened"
Can you post the whole code for this?
What is triggering your ajax call? A form submit event? Why are you using $.ajax rather than $.get or $.post?
I think you're making this harder than it is. Get the value of your input field first (and give your field an ID attribute, save the browser some work), use that to create your parameters to send to the processing page, and fire a nice, normal $.get request without all this mucking about trying to modify values in an XMLHTTP request on the fly.
|All times are GMT +1. The time now is 12:49 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.