I currently have it set up so that to navigate to various pages you click links on index.php, which then load into the content box of index.php.
I currently have a form on one of those pages that once submitted, I would like to redirect to the index.php page. But instead of displaying the default content on index.php, I'd like to specify the page loaded into the content box.
Is there a way to do this using a header? eg. header('Location: index.php#<contentboxpagehere>'); ??
Thanks!
So if I have understood correctly, you have a form and after a successful submission you want to redirect to the front page and display the right output message with an AJAX call in your defined page container.
You can achieve that in many ways. Keeping it simple and PHP you can do that with either a POST or GET request on the index page passing the container id you want to call in your front page AJAX container.
Using GET, pass URL parameter like: index.php?cbpId=success
Get the $_GET['cbpId'] and load the right content on the front page.
Related
First of all, thanks to anyone who tries to crack their head over this.. I already got 12 stitches.
This is what I have:
mysite.com/documentation - documentation page with menu div and content div (content div will be populated by Ajax when clicking on item in menu div).
mysite.com/documentation/subject-1-content - the actual content page of a menu item in the documentation page. This will be populated into the div by Ajax.
My problem is that if someone goes directly to mysite.com/documentation/subject-1-content , they get to the actual content and not the documentation page with this content populated in the div.
Is it possible at all to redirect a URL to a different URL + to activate an Ajax that calls the content of the first URL + not create an infinite loop of redirections?
Thank you in advance.
If I understand correctly you want to make a redirect if the page is not accessed through an ajax call.
Ajax calls pass a header called HTTP_X_REQUESTED_WITH. I'm assuming you are using PHP as server side so the code to detect the header and redirect in case it is empty (direct call to the page) would be:
if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) {
header("Location: mysite.com/documentation");
die;
}
//rest of your code
If you need to do it on the client side, you can make the content page mysite.com/documentation/subject-1-content redirect automatically to the documentation page possibly with a query param or hash, and the documentation page can read that param and load the required ajax content
Suppose i have an URL example.com, i want read the source of that page and get a particular link like example1.com and make a clickable event on it ,means that represents user had click the link from that URL example.com to example1.com.
You will need to first make an ajax call to that page to get the content to parse, then parse the webpage content with the link in your case example.com then go to the page (with or without click event).
Requesting Webpage
You will need some sort of ajax call to get the contents of the webpage for parsing.
See jQuery Ajax
Parsing
Get the #id or .class where the link you need is located (within the parsing function).
see jQuery Parsing
Redirecting
Click event isn't necessarly needed if you can just redirect to that link when you get it but this answer here has both information you need about click/redirecting with JS.
Good luck.
Is it possible to make changes to the page source content through Ajax loaded by a jsp include in the main jsp ?
If not is it possible to reload that portion of the page alone (the jsp that loads some of the content) and to have a portion of the content in the page source changed ?
Details:
I've a variable called page this var gets its content from a java controller as a map of <String key,map<String key,String value>then it performs multiple actions and adds different params to the map, convert it to JSON and sends it to a jsp.
Recently I wanted to do something different,I want to add a param to the 'page' variable called contentOfThePage this variable gets its content dynamically when the document is fully loaded, after that I perform an Ajax request to the controller to add the new param, but the problem is that the new changes never makes it to the page source unless i reload the page or i navigate to another page and this is causing a lot of trouble as the page source may contain the page content of the previous page!
Any idea on how to avoid this and make changes to the page source (NOT DOM) directly ?
keep in mind that the contents are added dynamically but i need a way to change the page source without impacting the performance by requesting a reload after the ajax request succeeded
First You want to update some data that is already there after page load
you already have a json so a rest call i assume
you call it using ajax
now you added something else that you want to change
Yes it can be done actually
but not with the present set
i assume you have a single jsp and trying to change that jsp
well fit whatever you want to change in a panel like a graph or anything else
Add a button to top of the panel and on click the button url must be to the rest call so then data will be updated
I too have faced a similar problem with graphs,
i needed the graph to give updated data without refreshing the whole page,
so i put it inside a panel and wrote a rest controller that gives data for the graph and put a refresh button that calls this rest controller. This let me then update the graph without refreshing the rest of page
In my project I have two Asp.net pages. The first is the main page and the second is the backend script page. When the user clicks the first page javascript will call the second page and should alert with a message like "Please confirm." but javascript is returning the whole html tag from second page. It doesn't return only error. How can I show the error from second page to render it in the first page? Please help me
1.Javascript code
http://www.mx7.com/view2/yCsMjYCaDlYctvSe
2.Return html whole second page
http://www.mx7.com/view2/yCsMmssWC8MkqLH8
Dont use Ajax call $.post instead submit your form with form tag. This will fix your issue.
if you want to use $.post method change your server page to retun only alert data instead whole page.
I am trying to dynamically change the URL of a Facebook Send button with Javascript, but I have had no success so far.
I have a page set up with a few inputs, and I would like the URL of the send button to take the fields value as parameters before it sends it. The problem is when I add the send button to the page, it generates the iframe code inside and even if I modify the href parameter later on, the iframe still keeps the original link in. I guess the solution would be to refresh the content of the send button somehow or add it after page load, once the fields have been completed, but I couldn't figure it out.
Thanks for your help.
You can try using the iFrame version of the like button instead the XFBML version. The like button can be post-loaded into the page after the form submission, via an AJAX call, in which you have passed the data filled up in the form.
You can't do this. Javascript can't be used to control an iFrame on a different domain than yours. This is due to the Same Origin Policy.
What you can do is change the parameters on you send button xfbml tag and then call FB.XFBML.parse(); so the button uses the new parameters.