JQuery :: Post Returns Data But Does Not Display It
Apr 20, 2011
$.post, it calls a php file which retrieves data from my database and should return a JSON datatype result. I checked on firebug, and it does successfully retrieve the data in JSON format. I however cannot get it to display on screen. I want to populate input fields with the result accordingly.
Here's a chunk of my javascript: (this function is being triggered by a dropdown)
function updateBillingAddFields(address_book_id) {
jQuery.post("ajax_checkout_confirmation.php", {
address_book_id: address_book_id,
action: 'get_shipping_add_details'
}, function(data){
var form_element = document.forms['address'];
form_element.elements['entry_name'].value = data.entry_name;
form_element.elements['entry_addr1'].value = data.entry_addr1;
form_element.elements['entry_addr2'].value = data.entry_addr2;
form_element.elements['entry_addr3'].value = data.entry_addr3;
form_element.elements['entry_addr4'].value = data.entry_addr4;
form_element.elements['entry_postcode'].value = data.entry_postcode;
form_element.elements['entry_state_name'].value = data.entry_state_name;
}, "json"); }
I tried putting alert inside my function, and it also doesn't show. I'm thinking it doesn't go inside the function at all.
I have two websites. One is my mediaWiki, and one is my production site.I would like to use the mediaWiki APIand $.post() to login to the wiki and retrieve pages from the Wiki.
Currently transitioning from a shared host to a dedicated server. The same code that works on the old server is not working on the dedicated server. It is a simple AJAX request like:
<code> function createXMLHttpRequest() { if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } }
With the code as is above, the requests works fine in IE. With Firefox it throws a 403 on the page. A call to the response.php page with parameters runs correctly outside of AJAX. Changing all POST requests to GET resolves the issue, but I would prefer not to have to change ALL POST requests to GET requests.
Does anyone know of a setting on the new server that can cause FireFox (1.5.x and 2.0.x) to return a 403 with an AJAX post call?
I have a form in which I preset some text inside a readonly, disabled textarea using javascript ('data' being the text): document.getElementById("link_of_current_view2").value = data;
However, once I call my .php script to process the form, the element is null. How do I get it to pass along that data, which is in the textbox when the user views the form? <div id="sendlink" class="contact_form" style="z-index:10;"> <a class="close" onclick="document.sendlink_form.reset();return false">CLOSE</a> <form id='sendlink_form' name='sendlink_form' method="post" action="sendlink.php" > <label for="link_of_current_view2">Link: </label> <textarea id="link_of_current_view2" name="_of_current_view2" class="link_of_current_view" rows="2" disabled="disabled" wrap="soft" size="58" value="" readonly="readonly" value=/>
I wonder if i can make the variable data which is [data] in jQuery.post( url, [data], [callback], [type] ) dynamic. for instance, this is the form i want to send,
I am writing a small data entry screen that will post the form data to a page and return a message. But i cannot get the Success or Error functions working properly.
Here's the code where strData is the posted querystring of:
I'm not sure whether it should be in a form and using the onsubmit or click of a button.
The white my notes section on the bottom left is a div area that is loaded with an Jquery Ajax call just like 2 other areas on the page. This works fine in IE, Safari (PC), Chrome but not in Firefox. It just shows blank white.
I'm building an application that uses calendars extensively, I have single calendars returning nicely but I working on a section that can return multiple calendars (eg. yearly overview) between certain date range ranges. It's working fine but the calendars are appended to the div when the server responds and not in the sequence they are called.
Here's the code I'm using:
Code:
function displayMultiCalendars(date1,date2,a) { $.get("<?=base_url();?>cal_center/get_date_range_total/"+date1+"/"+date2, function(data) {
[code].....
So, is there any way of making sure that they return in sequence? I'm sure there's another/better way of looping but I'm not the best with the js/jquery.
Either I'm having a really dim Friday, or something strange is going on. I'm trying to add a method to the Validator plugin, using the following regex:
I'm a total JS/jQuery newbie, and I'm having a problem using jQuery's load() to POST data to a remote PHP script and rewrite a DIV with whatever the server sent back.
Using a proxy in between, I can see that the JS script isn't sending anything, so I guess there's something wrong in the JS code I send to the browser [code]...
i want to send data(inputdata) using jQuery to a php script, the displaying the returned data(returndata) in a div but what happened that the (inputdata) don't get send this is my code it will explain it self better: HTMLfile.HTML
<HTML> <head> <script type="text/javascript" src="jquery.js"></script> <SCRIPT language="JavaScript"> function swapContent(inputdata){ [Code]...
I have some radio buttons and do a jquery post on click. Something like this: $.post("method", { value: value }, function(data) { alert(data); }); the value data does have the correct result, but my problem is the page doesn't refresh to that data.
I am new to all this but making good progress and having fun in the process. I have written quite a bit over recent weeks (including a few $.post / $.ajax calls) for various sites/applications but this one is really puzzling me. Here is a snippet of code that is causing me problems.
[Code]....
The problem is that execution jumps from line 2 to line 6 ... ignoring the function(data) and I am not sure why. I get the correct value of "team" arriving at the perl script .... and the perl writes the correct json back. I just can't think where else I need to look to debug this - as I said, I have done something similar 5-6 times over the last few weeks - all without a problem. So I am sure I am doing something stupid here.
The script below works, but only returns one headline/url from the html list.I am coming from a procedural background and know there must be a better way to pass all the urls and headlines (the link text) to my PHP script, which populates my database, but even after reading 'Jquery in Action' I am flummoxed.how to attack this problem? The .each portion of my script does not seem to work as I expect it to. I have also tried append, which would seem to be a solution ... really all I need is the "which" value from the url, so passing a simple array of those values to PHP would suffice.
I have been tearing my hair out with this for the past 12 or so hours and am no closer to a solution than when I began.
I have a jquery function to dynamically create <li> tags for an unordered list:
$(function() { var idealist = $('#idealist'); $('.checklist').click(function(event){ item = '';
[Code].....
This is working fine. The problem is I need to somehow pull the ids from each <li> tag into a string or an array that can be made available somehow to php code for further processing. I can create the string or array within my jquery function but can't figure out how to make that available to php.
I then delete testFile.txt and click on 'Submit' without refreshing, and this time, it does NOT create testFile.txt - and hence, my guess is that it is not calling on functions.php, and of course, alert is empty as usual.
What I want to do is this: I want to be able to click on the Submit button - without refreshing the page - and return data from functions.php and display it within a div tag on index.php What am I doing wrong to get an empty alert?
The data is a serilaized form that "alerts" correctly with all the data using this
[code]....
The alert gives me a string like product=p1&qty=1&product=p2&qty=2 But when I try to php echo out the results on basket-calc.php I get an "empty" array [code]...
1). Once my form posts, all the information stays in the post. How do I get it to blank. Is this where I set cache to false or is that something else? 2). I am using classic ASP and once I do my insert to sql server I retrieve the new record's ID, how do I get that returned back as part of the post? Some background: I am trying to submit a form, pull the id, and then requery all records for a user and display them in a div below the blank form without recycling the page.