Site URL is getting prefixed to external links on data returned from an AJAX call |
[eluser]Unknown[/eluser]
I've inherited a project which is just a intranet document storage type of site. There's a drop down list of categories and a table that gets filled with the different documents associated with those categories. When an option in the drop down is selected jQuery captures it and uses ajax to build a querystring (a CI happy URL) and then it eventually returns a string that is the html for a I get this back: <tr><td class='fileName'><a href='sitename.sitename.com/salesadmin/Education/Education-Collection-Process-and-Chargeback-Policy.doc' target='_blank'>Education Collection Process and Chargeback Policy</a><p class='fileDescription'></p></td><td class='fileExtension'><p class=doc>doc</p></td><td class='fileModed'>2010-08-10 07:52:30</td><td class='btn'><a class='btnEditLine' name='5' href='[removed]' title='Click to EDIT: "Education Collection Process and Chargeback Policy"'>Edit</a></td><td class='btn'><a class='btnDeleteLine' name='5' href='[removed]' title='Click to DELETE: "Education Collection Process and Chargeback Policy"'>Delete</a></td></tr> The href is correct, it is pointing to where the downloadable files are located. But for some reason when I roll over the links in the browser they are being prefixed with the site url: http://kopmacwwwo1.sitename.com/Internal...Policy.doc I console.log everything right up to where it is inserted into the tbody and it is correct. Is this something CI is doing and if so how do I correct it? Thanks Edit: I should add that when the site first loads the links are fine, but that is a different process, all PHP. This only occurs when the table data is being generated from AJAX. Also, anchor() and site_url() are not being used as far as I can tell. On the master header file the original developer had a couple of hidden inputs and one of them is used to pull the base url <input id='site_url_for_ajax' type='hidden' value="<?php echo $site_url_for_ajax ?>" /> Here's the JS code that makes the AJAX call if that helps: // ajax request triggered by catagory drop down menu selection or by other functions getCatagoriesItems: function () { // call function in master.js file to block the whole web page using blockUI blockPage(); // unbind previous evant handlers to edit and delete buttons to free memory (not sure if you have to do this, but better safe than sorry) $(".btnEditLine").unbind(); $(".btnDeleteLine").unbind(); // get base url of current site var baseurl = $("#site_url_for_ajax").val(); // get admin type var adminType = $("#admin_type").val() // get catagory id var catID = $("#catagoryDropDownList option ![]() // get the id of the selected item from the drop down list. This will correspond with the table name in the database var queryString = baseurl + "admin/ajaxCatagorySelection/" + catID + "/" + adminType; // run AJAX GET $.get(queryString, function(data) { // push data into obj var var obj = jQuery.parseJSON(data); // dump data into table when request is successful $("#dataResultsTable tbody").html(JSONParser.parseAdminDropDownSelectedJSON(obj)); // rebind event handlers to edit buttons bindEditButtonEventListener(); // rebind event handlers to delete buttons bindDeleteButtonEventHandler(); // unblock page when done $.unblockUI(); }); }, |
Welcome Guest, Not a member yet? Register Sign In |