Solved

ajax post not working in safari

Posted on 2012-12-27
4
635 Views
Last Modified: 2012-12-31
I have a click function that runs a jquery ajax post.
it works in all browsers except for safari.
what is wrong with this code?
function submitCart () {
$.post(
     "scripts/savecart.asp",
     $("#form1").serialize()
);}

Open in new window

0
Comment
Question by:rivkamak
4 Comments
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 125 total points
ID: 38726682
Not enough information to tell you.

What version of jQuery, Safari version/platform, error messages?
0
 
LVL 25

Assisted Solution

by:Kyle Hamilton
Kyle Hamilton earned 125 total points
ID: 38726688
you should include some error handling in your script, at least to marrow down the problem. look up jquery ajax error handling
0
 
LVL 20

Assisted Solution

by:Mark Brady
Mark Brady earned 125 total points
ID: 38726702
If you have get an error in Safari then you probably get at least a warning in other browsers. Open developer tools or firebug or whatever you use and check both the console and the network tab while you run the script.  [Ctrl + Shift + i] in google chrome brings up the developer tools. Click on the Network tab and reload the page or submit the form and see the call that goes out and the response. It shouldn't be to hard to figure it out.

Can you give us a link to the problem page?
0
 
LVL 11

Accepted Solution

by:
mcnute earned 125 total points
ID: 38727093
try to write it like so to get some error information:

$.ajax({
				url: 'scripts/savecart.asp',
				data: $("#form1").serialize(),
				error: function (XMLHttpRequest, textStatus, errorThrown) {
					console.log(textStatus+' '+errorThrown);
				},
				success: function(data) {
					console.log(data); // or if you're not using chrome or firebug alert(data);
				}
				});

Open in new window


This will give you at least an error handling code like 500, 404 or 302 or similar.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now